Merge pull request #8347 from thalesmg/fix-sub-deny-hook-50
fix(hooks): return error on hook-removed subscription rather than deleting it (5.0)
This commit is contained in:
commit
88746c7c11
|
@ -527,9 +527,9 @@ handle_in(
|
||||||
TupleTopicFilters2 =
|
TupleTopicFilters2 =
|
||||||
lists:foldl(
|
lists:foldl(
|
||||||
fun
|
fun
|
||||||
({{Topic, Opts = #{delete := true}}, _QoS}, Acc) ->
|
({{Topic, Opts = #{deny_subscription := true}}, _QoS}, Acc) ->
|
||||||
Key = {Topic, maps:without([delete], Opts)},
|
Key = {Topic, maps:without([deny_subscription], Opts)},
|
||||||
lists:keydelete(Key, 1, Acc);
|
lists:keyreplace(Key, 1, Acc, {Key, ?RC_UNSPECIFIED_ERROR});
|
||||||
(Tuple = {Key, _Value}, Acc) ->
|
(Tuple = {Key, _Value}, Acc) ->
|
||||||
lists:keyreplace(Key, 1, Acc, Tuple)
|
lists:keyreplace(Key, 1, Acc, Tuple)
|
||||||
end,
|
end,
|
||||||
|
|
|
@ -727,7 +727,7 @@ t_handle_in_empty_client_subscribe_hook(Config) when is_list(Config) ->
|
||||||
{ok, _} = emqtt:connect(C),
|
{ok, _} = emqtt:connect(C),
|
||||||
try
|
try
|
||||||
{ok, _, RCs} = emqtt:subscribe(C, <<"t">>),
|
{ok, _, RCs} = emqtt:subscribe(C, <<"t">>),
|
||||||
?assertEqual([], RCs),
|
?assertEqual([?RC_UNSPECIFIED_ERROR], RCs),
|
||||||
ok
|
ok
|
||||||
after
|
after
|
||||||
emqtt:disconnect(C)
|
emqtt:disconnect(C)
|
||||||
|
@ -791,5 +791,5 @@ recv_msgs(Count, Msgs) ->
|
||||||
end.
|
end.
|
||||||
|
|
||||||
client_subscribe_delete_all_hook(_ClientInfo, _Username, TopicFilter) ->
|
client_subscribe_delete_all_hook(_ClientInfo, _Username, TopicFilter) ->
|
||||||
EmptyFilters = [{T, Opts#{delete => true}} || {T, Opts} <- TopicFilter],
|
EmptyFilters = [{T, Opts#{deny_subscription => true}} || {T, Opts} <- TopicFilter],
|
||||||
{stop, EmptyFilters}.
|
{stop, EmptyFilters}.
|
||||||
|
|
Loading…
Reference in New Issue