Merge pull request #10131 from emqx/topic-rewrite-failed
fix: topic rewrite failed if clientid is an atom()
This commit is contained in:
commit
7baad16f23
|
@ -155,11 +155,11 @@ rewrite(Topic, MP, Dest, Binds) ->
|
|||
NewTopic.
|
||||
|
||||
fill_client_binds(#{clientid := ClientId, username := Username}) ->
|
||||
filter_client_binds([{"%c", ClientId}, {"%u", Username}]);
|
||||
filter_client_binds([{"%c", bin(ClientId)}, {"%u", bin(Username)}]);
|
||||
|
||||
fill_client_binds(#message{from = ClientId, headers = Headers}) ->
|
||||
Username = maps:get(username, Headers, undefined),
|
||||
filter_client_binds([{"%c", ClientId}, {"%u", Username}]).
|
||||
filter_client_binds([{"%c", bin(ClientId)}, {"%u", bin(Username)}]).
|
||||
|
||||
filter_client_binds(Binds) ->
|
||||
lists:filter(fun({_, undefined}) -> false;
|
||||
|
@ -184,3 +184,7 @@ validate_topic(Type, Topic) ->
|
|||
error:Reason ->
|
||||
{error, Reason}
|
||||
end.
|
||||
|
||||
bin(S) when is_binary(S) -> S;
|
||||
bin(S) when is_list(S) -> list_to_binary(S);
|
||||
bin(S) when is_atom(S) -> atom_to_binary(S, utf8).
|
||||
|
|
|
@ -1,7 +1,8 @@
|
|||
%% -*- mode: erlang -*-
|
||||
%% Unless you know what you are doing, DO NOT edit manually!!
|
||||
{VSN,
|
||||
[{<<"4\\.4\\.[6-8]">>,
|
||||
[{"4.4.9",[{load_module,emqx_mod_rewrite,brutal_purge,soft_purge,[]}]},
|
||||
{<<"4\\.4\\.[6-8]">>,
|
||||
[{load_module,emqx_modules,brutal_purge,soft_purge,[]},
|
||||
{load_module,emqx_mod_acl_internal,brutal_purge,soft_purge,[]},
|
||||
{load_module,emqx_mod_delayed,brutal_purge,soft_purge,[]},
|
||||
|
@ -38,7 +39,8 @@
|
|||
{load_module,emqx_mod_sup,brutal_purge,soft_purge,[]}
|
||||
]},
|
||||
{<<".*">>,[]}],
|
||||
[{<<"4\\.4\\.[6-8]">>,
|
||||
[{"4.4.9",[{load_module,emqx_mod_rewrite,brutal_purge,soft_purge,[]}]},
|
||||
{<<"4\\.4\\.[6-8]">>,
|
||||
[{load_module,emqx_modules,brutal_purge,soft_purge,[]},
|
||||
{load_module,emqx_mod_acl_internal,brutal_purge,soft_purge,[]},
|
||||
{load_module,emqx_mod_delayed,brutal_purge,soft_purge,[]},
|
||||
|
|
Loading…
Reference in New Issue