fix bot-emulator-users

This commit is contained in:
2026-05-28 21:55:34 +03:00
parent d2483ada15
commit 732e7c81b4
5 changed files with 161 additions and 70 deletions
+11 -3
View File
@@ -101,8 +101,16 @@ list_users(Req) ->
-spec parse_user_filters(cowboy_req:req()) -> map().
parse_user_filters(Req) ->
Qs = cowboy_req:parse_qs(Req),
RoleBin = proplists:get_value(<<"role">>, Qs),
StatusBin = proplists:get_value(<<"status">>, Qs),
#{
role => proplists:get_value(<<"role">>, Qs),
status => proplists:get_value(<<"status">>, Qs),
role => convert_to_atom(RoleBin),
status => convert_to_atom(StatusBin),
q => proplists:get_value(<<"q">>, Qs)
}.
}.
convert_to_atom(undefined) -> undefined;
convert_to_atom(Bin) when is_binary(Bin) ->
try binary_to_existing_atom(Bin, utf8)
catch error:badarg -> Bin
end.