Skip to content

Commit

Permalink
Merge pull request #3359 from esl/inbox_quick_improvements
Browse files Browse the repository at this point in the history
Inbox quick improvements
  • Loading branch information
vkatsuba authored Oct 25, 2021
2 parents e09d453 + 5c88861 commit 4109562
Showing 1 changed file with 12 additions and 13 deletions.
25 changes: 12 additions & 13 deletions src/inbox/mod_inbox_muclight.erl
Original file line number Diff line number Diff line change
Expand Up @@ -128,10 +128,11 @@ maybe_remove_inbox_row(HostType, Room, Remote, true) ->
Sender :: jid:jid(),
Packet :: exml:element(),
Acc :: mongoose_acc:t()) -> ok.
write_to_inbox(HostType, RoomUser, Remote, Remote, Packet, Acc) ->
mod_inbox_utils:write_to_sender_inbox(HostType, Remote, RoomUser, Packet, Acc);
write_to_inbox(HostType, RoomUser, Remote, _Sender, Packet, Acc) ->
mod_inbox_utils:write_to_receiver_inbox(HostType, RoomUser, Remote, Packet, Acc).
write_to_inbox(HostType, RoomUser, Remote, Sender, Packet, Acc) ->
case jid:are_equal(Remote, Sender) of
true -> mod_inbox_utils:write_to_sender_inbox(HostType, Remote, RoomUser, Packet, Acc);
false -> mod_inbox_utils:write_to_receiver_inbox(HostType, RoomUser, Remote, Packet, Acc)
end.

%%%%%%%
%% Predicate funs
Expand All @@ -158,15 +159,13 @@ is_change_aff_message(User, Packet, Role) ->

-spec system_message_type(User :: jid:jid(), Packet :: exml:element()) -> invite | kick | other.
system_message_type(User, Packet) ->
IsInviteMsg = is_invitation_message(User, Packet),
IsNewOwnerMsg = is_new_owner_message(User, Packet),
IsKickedMsg = is_kicked_message(User, Packet),
if IsInviteMsg orelse IsNewOwnerMsg ->
invite;
IsKickedMsg ->
kick;
true ->
other
case {is_invitation_message(User, Packet),
is_new_owner_message(User, Packet),
is_kicked_message(User, Packet)} of
{true, _, _} -> invite;
{_, true, _} -> invite;
{_, _, true} -> kick;
_ -> other
end.

-spec is_invitation_message(jid:jid(), exml:element()) -> boolean().
Expand Down

0 comments on commit 4109562

Please sign in to comment.