Merge pull request #13537 from thalesmg/20240729-r57-auto-decode-payload-kprodu
feat: attempt to automatically decode `payload` similar to key and message templates
This commit is contained in:
commit
5b50d5433a
|
@ -469,7 +469,7 @@ render_topic({fixed, KafkaTopic}, _Message) ->
|
||||||
KafkaTopic;
|
KafkaTopic;
|
||||||
render_topic({dynamic, Template}, Message) ->
|
render_topic({dynamic, Template}, Message) ->
|
||||||
try
|
try
|
||||||
iolist_to_binary(emqx_template:render_strict(Template, Message))
|
iolist_to_binary(emqx_template:render_strict(Template, {emqx_jsonish, Message}))
|
||||||
catch
|
catch
|
||||||
error:_Errors ->
|
error:_Errors ->
|
||||||
throw(bad_topic)
|
throw(bad_topic)
|
||||||
|
|
|
@ -967,12 +967,7 @@ t_dynamic_topics(Config) ->
|
||||||
RuleTopic,
|
RuleTopic,
|
||||||
[
|
[
|
||||||
{bridge_name, ActionName}
|
{bridge_name, ActionName}
|
||||||
],
|
]
|
||||||
#{
|
|
||||||
sql =>
|
|
||||||
<<"select *, json_decode(payload) as payload from \"", RuleTopic/binary,
|
|
||||||
"\" ">>
|
|
||||||
}
|
|
||||||
),
|
),
|
||||||
?assertStatusAPI(Type, ActionName, <<"connected">>),
|
?assertStatusAPI(Type, ActionName, <<"connected">>),
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue