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:
Andrew Mayorov 2023-09-16 01:34:05 +04:00
parent 2dae8020ec
commit 7c4f68dd3d
No known key found for this signature in database
GPG Key ID: 2837C62ACFBFED5D
2 changed files with 7 additions and 7 deletions

View File

@ -92,7 +92,7 @@
-export([enrich_delivers/3]).
% Utilities
-export([should_discard/1]).
-export([should_keep/1]).
% Tests only
-export([get_session_conf/2]).
@ -497,12 +497,12 @@ on_dropped_qos2_msg(PacketId, Msg, RC) ->
%%--------------------------------------------------------------------
-spec should_discard(message() | emqx_types:deliver()) -> boolean().
should_discard(MsgDeliver) ->
is_banned_msg(MsgDeliver).
-spec should_keep(message() | emqx_types:deliver()) -> boolean().
should_keep(MsgDeliver) ->
not is_banned_msg(MsgDeliver).
is_banned_msg(#message{from = ClientId}) ->
[] =:= emqx_banned:look_up({clientid, ClientId}).
[] =/= emqx_banned:look_up({clientid, ClientId}).
%%--------------------------------------------------------------------

View File

@ -211,10 +211,10 @@ open(ClientInfo = #{clientid := ClientId}, _ConnInfo) ->
end.
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},
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}.
%%--------------------------------------------------------------------