Skip to content

Commit

Permalink
fix: retainer message format time by rfc3339
Browse files Browse the repository at this point in the history
  • Loading branch information
DDDHuang committed Aug 31, 2021
1 parent 5b75fdd commit cac08cd
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
4 changes: 2 additions & 2 deletions apps/emqx_retainer/src/emqx_retainer_api.erl
Expand Up @@ -46,7 +46,7 @@ message_props() ->
{topic, string, <<"MQTT Topic">>},
{qos, string, <<"MQTT QoS">>},
{payload, string, <<"MQTT Payload">>},
{publish_at, string, <<"publish datetime">>},
{publish_at, string, <<"publish datetime by rfc 3339">>},
{from_clientid, string, <<"publisher ClientId">>},
{from_username, string, <<"publisher Username">>}
]).
Expand Down Expand Up @@ -170,7 +170,7 @@ format_message(#message{id = ID, qos = Qos, topic = Topic, from = From, timestam
#{msgid => emqx_guid:to_hexstr(ID),
qos => Qos,
topic => Topic,
publish_at => erlang:list_to_binary(emqx_mgmt_util:strftime(Timestamp div 1000)),
publish_at => emqx_rule_funcs:unix_ts_to_rfc3339(Timestamp div 1000, second),
from_clientid => to_bin_string(From),
from_username => maps:get(username, Headers, <<>>)
}.
Expand Down
4 changes: 3 additions & 1 deletion apps/emqx_rule_engine/src/emqx_rule_funcs.erl
Expand Up @@ -873,7 +873,9 @@ now_timestamp(Unit) ->
time_unit(<<"second">>) -> second;
time_unit(<<"millisecond">>) -> millisecond;
time_unit(<<"microsecond">>) -> microsecond;
time_unit(<<"nanosecond">>) -> nanosecond.
time_unit(<<"nanosecond">>) -> nanosecond;
time_unit(Unit) when is_atom(Unit) -> Unit.


%% @doc This is for sql funcs that should be handled in the specific modules.
%% Here the emqx_rule_funcs module acts as a proxy, forwarding
Expand Down

0 comments on commit cac08cd

Please sign in to comment.