Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WIP] event_pusher check if the recipient is not a room #3551

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 12 additions & 4 deletions src/event_pusher/mod_event_pusher_hook_translator.erl
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@

-include("jlib.hrl").
-include("mod_event_pusher_events.hrl").
-include("mongoose.hrl").

-export([start/2, stop/1]).
-export([user_send_packet/4,
Expand Down Expand Up @@ -57,10 +58,17 @@ filter_local_packet({From, To = #jid{lserver = Host}, Acc0, Packet}) ->
Acc = case chat_type(Acc0) of
false -> Acc0;
Type ->
Event = #chat_event{type = Type, direction = out,
from = From, to = To, packet = Packet},
NewAcc = mod_event_pusher:push_event(Acc0, Host, Event),
merge_acc(Acc0, NewAcc)
case mongoose_lib:is_to_room(To) of
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually, Type is the message type, that is, it can be the atom groupchat, so you might as well filter there too, you might want to call is_to_room only if the message is actually to a groupchat.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, true

true ->
?LOG_WARNING(#{what => to_room, jid => To, acc => Acc0}),
Acc0;
false ->
Event = #chat_event{type = Type, direction = out,
from = From, to = To, packet = Packet},
NewAcc = mod_event_pusher:push_event(Acc0, Host, Event),
merge_acc(Acc0, NewAcc)
end

end,
{From, To, Acc, Packet}.

Expand Down
2 changes: 1 addition & 1 deletion src/mongoose_lib.erl
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
-export([wait_until/2, wait_until/3]).
-export([parse_ip_netmask/1]).

-export([get_message_type/1, does_local_user_exist/3]).
-export([get_message_type/1, does_local_user_exist/3, is_to_room/1]).

%% Private, just for warning
-export([deprecated_logging/1]).
Expand Down