Merge pull request #6822 from HJianBo/more-fields-for-webhook
Ensure connected_at field for connect/connack/disconnected event
This commit is contained in:
commit
b19441df70
|
@ -1,6 +1,6 @@
|
||||||
{application, emqx_web_hook,
|
{application, emqx_web_hook,
|
||||||
[{description, "EMQ X WebHook Plugin"},
|
[{description, "EMQ X WebHook Plugin"},
|
||||||
{vsn, "4.3.8"}, % strict semver, bump manually!
|
{vsn, "4.3.9"}, % strict semver, bump manually!
|
||||||
{modules, []},
|
{modules, []},
|
||||||
{registered, [emqx_web_hook_sup]},
|
{registered, [emqx_web_hook_sup]},
|
||||||
{applications, [kernel,stdlib,ehttpc]},
|
{applications, [kernel,stdlib,ehttpc]},
|
||||||
|
|
|
@ -5,9 +5,10 @@
|
||||||
{load_module,emqx_web_hook_app,brutal_purge,soft_purge,[]},
|
{load_module,emqx_web_hook_app,brutal_purge,soft_purge,[]},
|
||||||
{load_module,emqx_web_hook,brutal_purge,soft_purge,[]},
|
{load_module,emqx_web_hook,brutal_purge,soft_purge,[]},
|
||||||
{load_module,emqx_web_hook_actions,brutal_purge,soft_purge,[]}]},
|
{load_module,emqx_web_hook_actions,brutal_purge,soft_purge,[]}]},
|
||||||
{<<"4\\.3\\.[3-7]">>,
|
{<<"4\\.3\\.[3-8]">>,
|
||||||
[{apply,{application,stop,[emqx_web_hook]}},
|
[{apply,{application,stop,[emqx_web_hook]}},
|
||||||
{load_module,emqx_web_hook_app,brutal_purge,soft_purge,[]},
|
{load_module,emqx_web_hook_app,brutal_purge,soft_purge,[]},
|
||||||
|
{load_module,emqx_web_hook,brutal_purge,soft_purge,[]},
|
||||||
{load_module,emqx_web_hook_actions,brutal_purge,soft_purge,[]}]},
|
{load_module,emqx_web_hook_actions,brutal_purge,soft_purge,[]}]},
|
||||||
{<<".*">>,[]}],
|
{<<".*">>,[]}],
|
||||||
[{<<"4\\.3\\.[0-2]">>,
|
[{<<"4\\.3\\.[0-2]">>,
|
||||||
|
@ -15,8 +16,9 @@
|
||||||
{load_module,emqx_web_hook_app,brutal_purge,soft_purge,[]},
|
{load_module,emqx_web_hook_app,brutal_purge,soft_purge,[]},
|
||||||
{load_module,emqx_web_hook,brutal_purge,soft_purge,[]},
|
{load_module,emqx_web_hook,brutal_purge,soft_purge,[]},
|
||||||
{load_module,emqx_web_hook_actions,brutal_purge,soft_purge,[]}]},
|
{load_module,emqx_web_hook_actions,brutal_purge,soft_purge,[]}]},
|
||||||
{<<"4\\.3\\.[3-7]">>,
|
{<<"4\\.3\\.[3-8]">>,
|
||||||
[{apply,{application,stop,[emqx_web_hook]}},
|
[{apply,{application,stop,[emqx_web_hook]}},
|
||||||
{load_module,emqx_web_hook_app,brutal_purge,soft_purge,[]},
|
{load_module,emqx_web_hook_app,brutal_purge,soft_purge,[]},
|
||||||
|
{load_module,emqx_web_hook,brutal_purge,soft_purge,[]},
|
||||||
{load_module,emqx_web_hook_actions,brutal_purge,soft_purge,[]}]},
|
{load_module,emqx_web_hook_actions,brutal_purge,soft_purge,[]}]},
|
||||||
{<<".*">>,[]}]}.
|
{<<".*">>,[]}]}.
|
||||||
|
|
|
@ -93,6 +93,7 @@ on_client_connect(ConnInfo = #{clientid := ClientId, username := Username, peern
|
||||||
, ipaddress => iolist_to_binary(ntoa(Peerhost))
|
, ipaddress => iolist_to_binary(ntoa(Peerhost))
|
||||||
, keepalive => maps:get(keepalive, ConnInfo)
|
, keepalive => maps:get(keepalive, ConnInfo)
|
||||||
, proto_ver => maps:get(proto_ver, ConnInfo)
|
, proto_ver => maps:get(proto_ver, ConnInfo)
|
||||||
|
, connected_at => maps:get(connected_at, ConnInfo)
|
||||||
},
|
},
|
||||||
send_http_request(ClientId, Params).
|
send_http_request(ClientId, Params).
|
||||||
|
|
||||||
|
@ -109,6 +110,7 @@ on_client_connack(ConnInfo = #{clientid := ClientId, username := Username, peern
|
||||||
, ipaddress => iolist_to_binary(ntoa(Peerhost))
|
, ipaddress => iolist_to_binary(ntoa(Peerhost))
|
||||||
, keepalive => maps:get(keepalive, ConnInfo)
|
, keepalive => maps:get(keepalive, ConnInfo)
|
||||||
, proto_ver => maps:get(proto_ver, ConnInfo)
|
, proto_ver => maps:get(proto_ver, ConnInfo)
|
||||||
|
, connected_at => maps:get(connected_at, ConnInfo)
|
||||||
, conn_ack => Rc
|
, conn_ack => Rc
|
||||||
},
|
},
|
||||||
send_http_request(ClientId, Params).
|
send_http_request(ClientId, Params).
|
||||||
|
@ -143,6 +145,7 @@ on_client_disconnected(#{clientid := ClientId, username := Username}, Reason, Co
|
||||||
, clientid => ClientId
|
, clientid => ClientId
|
||||||
, username => maybe(Username)
|
, username => maybe(Username)
|
||||||
, reason => stringfy(maybe(Reason))
|
, reason => stringfy(maybe(Reason))
|
||||||
|
, connected_at => maps:get(connected_at, ConnInfo)
|
||||||
, disconnected_at => maps:get(disconnected_at, ConnInfo, erlang:system_time(millisecond))
|
, disconnected_at => maps:get(disconnected_at, ConnInfo, erlang:system_time(millisecond))
|
||||||
},
|
},
|
||||||
send_http_request(ClientId, Params).
|
send_http_request(ClientId, Params).
|
||||||
|
|
|
@ -52,7 +52,8 @@ prop_client_connect() ->
|
||||||
username => maybe(maps:get(username, ConnInfo)),
|
username => maybe(maps:get(username, ConnInfo)),
|
||||||
ipaddress => peer2addr(maps:get(peername, ConnInfo)),
|
ipaddress => peer2addr(maps:get(peername, ConnInfo)),
|
||||||
keepalive => maps:get(keepalive, ConnInfo),
|
keepalive => maps:get(keepalive, ConnInfo),
|
||||||
proto_ver => maps:get(proto_ver, ConnInfo)
|
proto_ver => maps:get(proto_ver, ConnInfo),
|
||||||
|
connected_at => maps:get(connected_at, ConnInfo)
|
||||||
}),
|
}),
|
||||||
true
|
true
|
||||||
end).
|
end).
|
||||||
|
@ -71,6 +72,7 @@ prop_client_connack() ->
|
||||||
ipaddress => peer2addr(maps:get(peername, ConnInfo)),
|
ipaddress => peer2addr(maps:get(peername, ConnInfo)),
|
||||||
keepalive => maps:get(keepalive, ConnInfo),
|
keepalive => maps:get(keepalive, ConnInfo),
|
||||||
proto_ver => maps:get(proto_ver, ConnInfo),
|
proto_ver => maps:get(proto_ver, ConnInfo),
|
||||||
|
connected_at => maps:get(connected_at, ConnInfo),
|
||||||
conn_ack => Rc
|
conn_ack => Rc
|
||||||
}),
|
}),
|
||||||
true
|
true
|
||||||
|
@ -106,6 +108,7 @@ prop_client_disconnected() ->
|
||||||
node => stringfy(node()),
|
node => stringfy(node()),
|
||||||
clientid => maps:get(clientid, ClientInfo),
|
clientid => maps:get(clientid, ClientInfo),
|
||||||
username => maybe(maps:get(username, ClientInfo)),
|
username => maybe(maps:get(username, ClientInfo)),
|
||||||
|
connected_at => maps:get(connected_at, ConnInfo),
|
||||||
disconnected_at => maps:get(disconnected_at, ConnInfo),
|
disconnected_at => maps:get(disconnected_at, ConnInfo),
|
||||||
reason => stringfy(Reason)
|
reason => stringfy(Reason)
|
||||||
}),
|
}),
|
||||||
|
|
|
@ -57,8 +57,7 @@ on_client_connected(ClientInfo = #{clientid := ClientId}, ConnInfo, Env) ->
|
||||||
connack => 0, %% XXX: connack will be removed in 5.0
|
connack => 0, %% XXX: connack will be removed in 5.0
|
||||||
keepalive => maps:get(keepalive, ConnInfo, 0),
|
keepalive => maps:get(keepalive, ConnInfo, 0),
|
||||||
clean_start => maps:get(clean_start, ConnInfo, true),
|
clean_start => maps:get(clean_start, ConnInfo, true),
|
||||||
expiry_interval => maps:get(expiry_interval, ConnInfo, 0),
|
expiry_interval => maps:get(expiry_interval, ConnInfo, 0)
|
||||||
connected_at => maps:get(connected_at, ConnInfo)
|
|
||||||
},
|
},
|
||||||
case emqx_json:safe_encode(NPresence) of
|
case emqx_json:safe_encode(NPresence) of
|
||||||
{ok, Payload} ->
|
{ok, Payload} ->
|
||||||
|
@ -95,7 +94,8 @@ common_infos(
|
||||||
sockport := SockPort
|
sockport := SockPort
|
||||||
},
|
},
|
||||||
_ConnInfo = #{proto_name := ProtoName,
|
_ConnInfo = #{proto_name := ProtoName,
|
||||||
proto_ver := ProtoVer
|
proto_ver := ProtoVer,
|
||||||
|
connected_at := ConnectedAt
|
||||||
}) ->
|
}) ->
|
||||||
#{clientid => ClientId,
|
#{clientid => ClientId,
|
||||||
username => Username,
|
username => Username,
|
||||||
|
@ -103,6 +103,7 @@ common_infos(
|
||||||
sockport => SockPort,
|
sockport => SockPort,
|
||||||
proto_name => ProtoName,
|
proto_name => ProtoName,
|
||||||
proto_ver => ProtoVer,
|
proto_ver => ProtoVer,
|
||||||
|
connected_at => ConnectedAt,
|
||||||
ts => erlang:system_time(millisecond)
|
ts => erlang:system_time(millisecond)
|
||||||
}.
|
}.
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
{application, emqx_modules,
|
{application, emqx_modules,
|
||||||
[{description, "EMQ X Module Management"},
|
[{description, "EMQ X Module Management"},
|
||||||
{vsn, "4.3.3"},
|
{vsn, "4.3.4"},
|
||||||
{modules, []},
|
{modules, []},
|
||||||
{applications, [kernel,stdlib]},
|
{applications, [kernel,stdlib]},
|
||||||
{mod, {emqx_modules_app, []}},
|
{mod, {emqx_modules_app, []}},
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
%% -*-: erlang -*-
|
%% -*-: erlang -*-
|
||||||
{VSN,
|
{VSN,
|
||||||
[
|
[
|
||||||
{"4.3.2", [
|
{<<"4\\.3\\.[2-3]">>, [
|
||||||
{load_module, emqx_mod_presence, brutal_purge, soft_purge, []}
|
{load_module, emqx_mod_presence, brutal_purge, soft_purge, []}
|
||||||
]},
|
]},
|
||||||
{"4.3.1", [
|
{"4.3.1", [
|
||||||
|
@ -16,7 +16,7 @@
|
||||||
{<<".*">>, []}
|
{<<".*">>, []}
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
{"4.3.2", [
|
{<<"4\\.3\\.[2-3]">>, [
|
||||||
{load_module, emqx_mod_presence, brutal_purge, soft_purge, []}
|
{load_module, emqx_mod_presence, brutal_purge, soft_purge, []}
|
||||||
]},
|
]},
|
||||||
{"4.3.1", [
|
{"4.3.1", [
|
||||||
|
|
Loading…
Reference in New Issue