fix(actions): fix republish actions payload is null

This commit is contained in:
Turtle 2021-08-04 14:10:45 +08:00 committed by turtleDeng
parent ff4229bb93
commit ac0639f6b1
2 changed files with 15 additions and 2 deletions

View File

@ -168,7 +168,7 @@ on_action_republish(Selected, _Envs = #{
flags = Flags,
headers = #{republish_by => ActId},
topic = emqx_rule_utils:proc_tmpl(TopicTks, Selected),
payload = emqx_rule_utils:proc_tmpl(PayloadTks, Selected),
payload = format_msg(PayloadTks, Selected),
timestamp = Timestamp
});
@ -191,7 +191,7 @@ on_action_republish(Selected, _Envs = #{
flags = #{dup => false, retain => false},
headers = #{republish_by => ActId},
topic = emqx_rule_utils:proc_tmpl(TopicTks, Selected),
payload = emqx_rule_utils:proc_tmpl(PayloadTks, Selected),
payload = format_msg(PayloadTks, Selected),
timestamp = erlang:system_time(millisecond)
}).
@ -206,3 +206,8 @@ on_action_create_do_nothing(ActId, Params) when is_binary(ActId) ->
on_action_do_nothing(Selected, Envs) when is_map(Selected) ->
emqx_rule_metrics:inc_actions_success(?bound_v('ActId', Envs)).
format_msg([], Data) ->
emqx_json:encode(Data);
format_msg(Tokens, Data) ->
emqx_rule_utils:proc_tmpl(Tokens, Data).

View File

@ -5,19 +5,23 @@
, {load_module, emqx_rule_engine, brutal_purge, soft_purge, []}
, {load_module, emqx_rule_registry, brutal_purge, soft_purge, []}
, {apply, {emqx_stats, cancel_update, [rule_registery_stats]}}
, {load_module, emqx_rule_actions, brutal_purge, soft_purge, []}
]},
{"4.3.1",
[ {load_module, emqx_rule_engine, brutal_purge, soft_purge, []}
, {load_module, emqx_rule_registry, brutal_purge, soft_purge, []}
, {apply, {emqx_stats, cancel_update, [rule_registery_stats]}}
, {load_module, emqx_rule_actions, brutal_purge, soft_purge, []}
]},
{"4.3.2",
[ {load_module, emqx_rule_registry, brutal_purge, soft_purge, []}
, {apply, {emqx_stats, cancel_update, [rule_registery_stats]}}
, {load_module, emqx_rule_engine, brutal_purge, soft_purge, []}
, {load_module, emqx_rule_actions, brutal_purge, soft_purge, []}
]},
{"4.3.3",
[ {load_module, emqx_rule_engine, brutal_purge, soft_purge, []}
, {load_module, emqx_rule_actions, brutal_purge, soft_purge, []}
]},
{<<".*">>, []}
],
@ -27,19 +31,23 @@
, {load_module, emqx_rule_engine, brutal_purge, soft_purge, []}
, {load_module, emqx_rule_registry, brutal_purge, soft_purge, []}
, {apply, {emqx_stats, cancel_update, [rule_registery_stats]}}
, {load_module, emqx_rule_actions, brutal_purge, soft_purge, []}
]},
{"4.3.1",
[ {load_module, emqx_rule_engine, brutal_purge, soft_purge, []}
, {load_module, emqx_rule_registry, brutal_purge, soft_purge, []}
, {apply, {emqx_stats, cancel_update, [rule_registery_stats]}}
, {load_module, emqx_rule_actions, brutal_purge, soft_purge, []}
]},
{"4.3.2",
[ {load_module, emqx_rule_registry, brutal_purge, soft_purge, []}
, {apply, {emqx_stats, cancel_update, [rule_registery_stats]}}
, {load_module, emqx_rule_engine, brutal_purge, soft_purge, []}
, {load_module, emqx_rule_actions, brutal_purge, soft_purge, []}
]},
{"4.3.3",
[ {load_module, emqx_rule_engine, brutal_purge, soft_purge, []}
, {load_module, emqx_rule_actions, brutal_purge, soft_purge, []}
]},
{<<".*">>, []}
]