fix: rewrite #share{} and return #share{}, not formated $share/group/topic

This commit is contained in:
JimMoen 2023-10-25 17:25:23 +08:00
parent afec6fa2f6
commit 53383991d9
No known key found for this signature in database
GPG Key ID: 87A520B4F76BA86D
1 changed files with 3 additions and 2 deletions

View File

@ -150,15 +150,16 @@ compile(Rules) ->
Rules
).
%% FIXME: rewrite #share{} and return #share{}, not formated $share/group/topic
match_and_rewrite(Topic, [], _) ->
Topic;
match_and_rewrite(Topic, [{Filter, MP, Dest} | Rules], Binds) ->
case emqx_topic:match(Topic, Filter) of
true -> rewrite(emqx_topic:get_shared_real_topic(Topic), MP, Dest, Binds);
true -> rewrite(Topic, MP, Dest, Binds);
false -> match_and_rewrite(Topic, Rules, Binds)
end.
rewrite(SharedRecord = #share{topic = Topic}, MP, Dest, Binds) ->
SharedRecord#share{topic = rewrite(Topic, MP, Dest, Binds)};
rewrite(Topic, MP, Dest, Binds) ->
case re:run(Topic, MP, [{capture, all_but_first, list}]) of
{match, Captured} ->