fix(coap): remove the leading `/` in assembling publish topic
This commit is contained in:
parent
f188808e67
commit
55c1a1868a
|
@ -153,7 +153,7 @@ init(
|
|||
mountpoint => Mountpoint
|
||||
}
|
||||
),
|
||||
|
||||
%% FIXME: it should coap.hearbeat instead of idle_timeout?
|
||||
Heartbeat = ?GET_IDLE_TIME(Config),
|
||||
#channel{
|
||||
ctx = Ctx,
|
||||
|
@ -447,6 +447,7 @@ enrich_conninfo(
|
|||
conninfo = ConnInfo
|
||||
}
|
||||
) ->
|
||||
%% FIXME: generate a random clientid if absent
|
||||
case Queries of
|
||||
#{<<"clientid">> := ClientId} ->
|
||||
Interval = maps:get(interval, emqx_keepalive:info(KeepAlive)),
|
||||
|
@ -467,6 +468,9 @@ enrich_clientinfo(
|
|||
{Queries, Msg},
|
||||
Channel = #channel{clientinfo = ClientInfo0}
|
||||
) ->
|
||||
%% FIXME:
|
||||
%% 1. generate a random clientid if absent;
|
||||
%% 2. assgin username, password to `undefined` if absent
|
||||
case Queries of
|
||||
#{
|
||||
<<"username">> := UserName,
|
||||
|
@ -542,6 +546,7 @@ process_connect(
|
|||
)
|
||||
of
|
||||
{ok, _Sess} ->
|
||||
%% FIXME: Token in cluster wide?
|
||||
RandVal = rand:uniform(?TOKEN_MAXIMUM),
|
||||
Token = erlang:list_to_binary(erlang:integer_to_list(RandVal)),
|
||||
NResult = Result#{events => [{event, connected}]},
|
||||
|
|
|
@ -69,17 +69,7 @@ handle_method(_, _, Msg, _, _) ->
|
|||
check_topic([]) ->
|
||||
error;
|
||||
check_topic(Path) ->
|
||||
Sep = <<"/">>,
|
||||
{ok,
|
||||
emqx_http_lib:uri_decode(
|
||||
lists:foldl(
|
||||
fun(Part, Acc) ->
|
||||
<<Acc/binary, Sep/binary, Part/binary>>
|
||||
end,
|
||||
<<>>,
|
||||
Path
|
||||
)
|
||||
)}.
|
||||
{ok, emqx_http_lib:uri_decode(iolist_to_binary(lists:join(<<"/">>, Path)))}.
|
||||
|
||||
get_sub_opts(#coap_message{options = Opts} = Msg) ->
|
||||
SubOpts = maps:fold(fun parse_sub_opts/3, #{}, Opts),
|
||||
|
@ -124,6 +114,10 @@ get_publish_qos(Msg) ->
|
|||
end.
|
||||
|
||||
apply_publish_opts(Msg, MQTTMsg) ->
|
||||
case emqx_coap_message:get_option(uri_query, Msg) of
|
||||
undefined ->
|
||||
MQTTMsg;
|
||||
Qs ->
|
||||
maps:fold(
|
||||
fun
|
||||
(<<"retain">>, V, Acc) ->
|
||||
|
@ -141,8 +135,9 @@ apply_publish_opts(Msg, MQTTMsg) ->
|
|||
Acc
|
||||
end,
|
||||
MQTTMsg,
|
||||
emqx_coap_message:get_option(uri_query, Msg)
|
||||
).
|
||||
Qs
|
||||
)
|
||||
end.
|
||||
|
||||
subscribe(#coap_message{token = <<>>} = Msg, _, _, _) ->
|
||||
reply({error, bad_request}, <<"observe without token">>, Msg);
|
||||
|
|
Loading…
Reference in New Issue