fix(coap): Ensure that the retain flag is a boolean value

This commit is contained in:
firest 2022-11-01 16:17:08 +08:00
parent 60492615ba
commit 3cc76c0adf
1 changed files with 7 additions and 1 deletions

View File

@ -121,7 +121,13 @@ apply_publish_opts(Msg, MQTTMsg) ->
maps:fold(
fun
(<<"retain">>, V, Acc) ->
Val = erlang:binary_to_atom(V),
Val =
case emqx_misc:safe_to_existing_atom(V) of
{ok, true} ->
true;
_ ->
false
end,
emqx_message:set_flag(retain, Val, Acc);
(<<"expiry">>, V, Acc) ->
Val = erlang:binary_to_integer(V),