mirror of
https://github.com/processone/ejabberd.git
synced 2024-11-20 16:15:59 +01:00
Restore args conversion of {"k":"v"} to tuple lists in mod_http_api
Switching to json compatible output did broke this, which caused issues in for example create_rooms_with_opts command.
This commit is contained in:
parent
aa02c4de1e
commit
c013a59d16
@ -332,6 +332,14 @@ format_arg({Elements},
|
||||
({Val}) when is_list(Val) ->
|
||||
format_arg({Val}, Tuple)
|
||||
end, Elements);
|
||||
format_arg(Map,
|
||||
{list, {_ElementDefName, {tuple, [{_Tuple1N, Tuple1S}, {_Tuple2N, Tuple2S}]}}})
|
||||
when is_map(Map) andalso
|
||||
(Tuple1S == binary orelse Tuple1S == string) ->
|
||||
maps:fold(
|
||||
fun(K, V, Acc) ->
|
||||
[{format_arg(K, Tuple1S), format_arg(V, Tuple2S)} | Acc]
|
||||
end, [], Map);
|
||||
format_arg(Elements,
|
||||
{list, {_ElementDefName, {list, _} = ElementDefFormat}})
|
||||
when is_list(Elements) ->
|
||||
|
@ -47,7 +47,8 @@ single_cases() ->
|
||||
single_test(http_restuple),
|
||||
single_test(http_list),
|
||||
single_test(http_tuple),
|
||||
single_test(http_list_tuple)]}.
|
||||
single_test(http_list_tuple),
|
||||
single_test(http_list_tuple_map)]}.
|
||||
|
||||
setup(_Config) ->
|
||||
M = <<"mod_example">>,
|
||||
@ -139,6 +140,13 @@ http_list_tuple(Config) ->
|
||||
?match(LTB, query(Config, "command_test_list_tuple", #{arg_list => LTA})),
|
||||
?match(LTB, query(Config, "command_test_list_tuple", #{arg_list => LTB})).
|
||||
|
||||
http_list_tuple_map(Config) ->
|
||||
LTA = #{<<"one">> => <<"uno">>, <<"dos">> => <<"two">>, <<"three">> => <<"tres">>},
|
||||
LTB = lists:sort([#{<<"element1">> => <<"one">>, <<"element2">> => <<"uno">>},
|
||||
#{<<"element1">> => <<"dos">>, <<"element2">> => <<"two">>},
|
||||
#{<<"element1">> => <<"three">>, <<"element2">> => <<"tres">>}]),
|
||||
?match(LTB, lists:sort(query(Config, "command_test_list_tuple", #{arg_list => LTA}))).
|
||||
|
||||
%%%==================================
|
||||
%%%% internal functions
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user