fix(api): client subscriptions formatter fun bad match

This commit is contained in:
DDDHuang 2022-01-25 11:10:32 +08:00
parent 6b020b4a01
commit e07ecd5211
2 changed files with 16 additions and 7 deletions

View File

@ -276,8 +276,7 @@ list_client_subscriptions(ClientId) ->
({_Node, List}) ->
erlang:is_list(List) andalso 0 < erlang:length(List)
end,
Expected = lists:filter(Filter, Results),
case Expected of
case lists:filter(Filter, Results) of
[] -> [];
[Result | _] -> Result
end.

View File

@ -513,11 +513,21 @@ subscribe_batch(post, #{bindings := #{clientid := ClientID}, body := TopicInfos}
subscribe_batch(#{clientid => ClientID, topics => Topics}).
subscriptions(get, #{bindings := #{clientid := ClientID}}) ->
{Node, Subs0} = emqx_mgmt:list_client_subscriptions(ClientID),
Subs = lists:map(fun({Topic, SubOpts}) ->
#{node => Node, clientid => ClientID, topic => Topic, qos => maps:get(qos, SubOpts)}
end, Subs0),
{200, Subs}.
case emqx_mgmt:list_client_subscriptions(ClientID) of
[] ->
{200, []};
{Node, Subs} ->
Formatter =
fun({Topic, SubOpts}) ->
#{
node => Node,
clientid => ClientID,
topic => Topic,
qos => maps:get(qos, SubOpts)
}
end,
{200, lists:map(Formatter, Subs)}
end.
set_keepalive(put, #{bindings := #{clientid := ClientID}, query_string := Query}) ->
case maps:find(<<"interval">>, Query) of