feat: attempt to automatically decode `payload` similar to key and message templates

This commit is contained in:
Thales Macedo Garitezi 2024-07-29 11:37:33 -03:00
parent 60aefd1065
commit 693d5dd394
2 changed files with 2 additions and 7 deletions

View File

@ -469,7 +469,7 @@ render_topic({fixed, KafkaTopic}, _Message) ->
KafkaTopic;
render_topic({dynamic, Template}, Message) ->
try
iolist_to_binary(emqx_template:render_strict(Template, Message))
iolist_to_binary(emqx_template:render_strict(Template, {emqx_jsonish, Message}))
catch
error:_Errors ->
throw(bad_topic)

View File

@ -967,12 +967,7 @@ t_dynamic_topics(Config) ->
RuleTopic,
[
{bridge_name, ActionName}
],
#{
sql =>
<<"select *, json_decode(payload) as payload from \"", RuleTopic/binary,
"\" ">>
}
]
),
?assertStatusAPI(Type, ActionName, <<"connected">>),