fix(session): make utility function names consistent
Before this commit behavior of `is_banned_msg/1` / `should_discard/1` were actually the exact opposite of their names. Co-Authored-By: Thales Macedo Garitezi <thalesmg@gmail.com>
This commit is contained in:
parent
2dae8020ec
commit
7c4f68dd3d
|
@ -92,7 +92,7 @@
|
||||||
-export([enrich_delivers/3]).
|
-export([enrich_delivers/3]).
|
||||||
|
|
||||||
% Utilities
|
% Utilities
|
||||||
-export([should_discard/1]).
|
-export([should_keep/1]).
|
||||||
|
|
||||||
% Tests only
|
% Tests only
|
||||||
-export([get_session_conf/2]).
|
-export([get_session_conf/2]).
|
||||||
|
@ -497,12 +497,12 @@ on_dropped_qos2_msg(PacketId, Msg, RC) ->
|
||||||
|
|
||||||
%%--------------------------------------------------------------------
|
%%--------------------------------------------------------------------
|
||||||
|
|
||||||
-spec should_discard(message() | emqx_types:deliver()) -> boolean().
|
-spec should_keep(message() | emqx_types:deliver()) -> boolean().
|
||||||
should_discard(MsgDeliver) ->
|
should_keep(MsgDeliver) ->
|
||||||
is_banned_msg(MsgDeliver).
|
not is_banned_msg(MsgDeliver).
|
||||||
|
|
||||||
is_banned_msg(#message{from = ClientId}) ->
|
is_banned_msg(#message{from = ClientId}) ->
|
||||||
[] =:= emqx_banned:look_up({clientid, ClientId}).
|
[] =/= emqx_banned:look_up({clientid, ClientId}).
|
||||||
|
|
||||||
%%--------------------------------------------------------------------
|
%%--------------------------------------------------------------------
|
||||||
|
|
||||||
|
|
|
@ -211,10 +211,10 @@ open(ClientInfo = #{clientid := ClientId}, _ConnInfo) ->
|
||||||
end.
|
end.
|
||||||
|
|
||||||
clean_session(ClientInfo, Session = #session{mqueue = Q}, Pendings) ->
|
clean_session(ClientInfo, Session = #session{mqueue = Q}, Pendings) ->
|
||||||
Q1 = emqx_mqueue:filter(fun emqx_session:should_discard/1, Q),
|
Q1 = emqx_mqueue:filter(fun emqx_session:should_keep/1, Q),
|
||||||
Session1 = Session#session{mqueue = Q1},
|
Session1 = Session#session{mqueue = Q1},
|
||||||
Pendings1 = emqx_session:enrich_delivers(ClientInfo, Pendings, Session),
|
Pendings1 = emqx_session:enrich_delivers(ClientInfo, Pendings, Session),
|
||||||
Pendings2 = lists:filter(fun emqx_session:should_discard/1, Pendings1),
|
Pendings2 = lists:filter(fun emqx_session:should_keep/1, Pendings1),
|
||||||
{true, Session1, Pendings2}.
|
{true, Session1, Pendings2}.
|
||||||
|
|
||||||
%%--------------------------------------------------------------------
|
%%--------------------------------------------------------------------
|
||||||
|
|
Loading…
Reference in New Issue