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}) -> ({_Node, List}) ->
erlang:is_list(List) andalso 0 < erlang:length(List) erlang:is_list(List) andalso 0 < erlang:length(List)
end, end,
Expected = lists:filter(Filter, Results), case lists:filter(Filter, Results) of
case Expected of
[] -> []; [] -> [];
[Result | _] -> Result [Result | _] -> Result
end. end.

View File

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