refactor: variable and func rename
This commit is contained in:
parent
ea81a924f1
commit
070e410c69
|
@ -484,13 +484,13 @@ handle_in(
|
||||||
{ok, Channel}
|
{ok, Channel}
|
||||||
end;
|
end;
|
||||||
handle_in(
|
handle_in(
|
||||||
Packet = ?SUBSCRIBE_PACKET(PacketId, Properties, TopicFilters),
|
SubPkt = ?SUBSCRIBE_PACKET(PacketId, Properties, TopicFilters),
|
||||||
Channel = #channel{clientinfo = ClientInfo}
|
Channel = #channel{clientinfo = ClientInfo}
|
||||||
) ->
|
) ->
|
||||||
case emqx_packet:check(Packet) of
|
case emqx_packet:check(SubPkt) of
|
||||||
ok ->
|
ok ->
|
||||||
TopicFilters0 = parse_topic_filters(TopicFilters),
|
TopicFilters0 = parse_topic_filters(TopicFilters),
|
||||||
TopicFilters1 = put_subid_in_subopts(Properties, TopicFilters0),
|
TopicFilters1 = enrich_subopts_subid(Properties, TopicFilters0),
|
||||||
TupleTopicFilters0 = check_sub_authzs(TopicFilters1, Channel),
|
TupleTopicFilters0 = check_sub_authzs(TopicFilters1, Channel),
|
||||||
HasAuthzDeny = lists:any(
|
HasAuthzDeny = lists:any(
|
||||||
fun({_TopicFilter, ReasonCode}) ->
|
fun({_TopicFilter, ReasonCode}) ->
|
||||||
|
@ -503,7 +503,10 @@ handle_in(
|
||||||
true ->
|
true ->
|
||||||
handle_out(disconnect, ?RC_NOT_AUTHORIZED, Channel);
|
handle_out(disconnect, ?RC_NOT_AUTHORIZED, Channel);
|
||||||
false ->
|
false ->
|
||||||
TopicFilters2 = [TopicFilter || {TopicFilter, 0} <- TupleTopicFilters0],
|
TopicFilters2 = [
|
||||||
|
TopicFilter
|
||||||
|
|| {TopicFilter, ?RC_SUCCESS} <- TupleTopicFilters0
|
||||||
|
],
|
||||||
TopicFilters3 = run_hooks(
|
TopicFilters3 = run_hooks(
|
||||||
'client.subscribe',
|
'client.subscribe',
|
||||||
[ClientInfo, Properties],
|
[ClientInfo, Properties],
|
||||||
|
@ -1879,7 +1882,7 @@ check_sub_authzs(
|
||||||
) ->
|
) ->
|
||||||
case emqx_access_control:authorize(ClientInfo, subscribe, Topic) of
|
case emqx_access_control:authorize(ClientInfo, subscribe, Topic) of
|
||||||
allow ->
|
allow ->
|
||||||
check_sub_authzs(More, Channel, [{TopicFilter, 0} | Acc]);
|
check_sub_authzs(More, Channel, [{TopicFilter, ?RC_SUCCESS} | Acc]);
|
||||||
deny ->
|
deny ->
|
||||||
check_sub_authzs(More, Channel, [{TopicFilter, ?RC_NOT_AUTHORIZED} | Acc])
|
check_sub_authzs(More, Channel, [{TopicFilter, ?RC_NOT_AUTHORIZED} | Acc])
|
||||||
end;
|
end;
|
||||||
|
@ -1895,9 +1898,9 @@ check_sub_caps(TopicFilter, SubOpts, #channel{clientinfo = ClientInfo}) ->
|
||||||
%%--------------------------------------------------------------------
|
%%--------------------------------------------------------------------
|
||||||
%% Enrich SubId
|
%% Enrich SubId
|
||||||
|
|
||||||
put_subid_in_subopts(#{'Subscription-Identifier' := SubId}, TopicFilters) ->
|
enrich_subopts_subid(#{'Subscription-Identifier' := SubId}, TopicFilters) ->
|
||||||
[{Topic, SubOpts#{subid => SubId}} || {Topic, SubOpts} <- TopicFilters];
|
[{Topic, SubOpts#{subid => SubId}} || {Topic, SubOpts} <- TopicFilters];
|
||||||
put_subid_in_subopts(_Properties, TopicFilters) ->
|
enrich_subopts_subid(_Properties, TopicFilters) ->
|
||||||
TopicFilters.
|
TopicFilters.
|
||||||
|
|
||||||
%%--------------------------------------------------------------------
|
%%--------------------------------------------------------------------
|
||||||
|
|
Loading…
Reference in New Issue