25
1
mirror of https://github.com/processone/ejabberd.git synced 2024-11-20 16:15:59 +01:00

ejabberd_sm: Fix routing of groupchat messages

As per RFC 6121, don't (re)route groupchat messages sent to a bare JID
or to an unavailable resource.
This commit is contained in:
Holger Weiss 2017-04-05 20:41:10 +02:00
parent 89f81c89da
commit 8bfb6fdd4e
2 changed files with 3 additions and 2 deletions

View File

@ -553,7 +553,7 @@ do_route(#presence{to = #jid{lresource = <<"">>} = To} = Packet) ->
end, get_user_present_resources(LUser, LServer)); end, get_user_present_resources(LUser, LServer));
do_route(#message{to = #jid{lresource = <<"">>}, type = T} = Packet) -> do_route(#message{to = #jid{lresource = <<"">>}, type = T} = Packet) ->
?DEBUG("processing message to bare JID:~n~s", [xmpp:pp(Packet)]), ?DEBUG("processing message to bare JID:~n~s", [xmpp:pp(Packet)]),
if T == chat; T == headline; T == normal; T == groupchat -> if T == chat; T == headline; T == normal ->
route_message(Packet); route_message(Packet);
true -> true ->
Lang = xmpp:get_lang(Packet), Lang = xmpp:get_lang(Packet),
@ -573,7 +573,7 @@ do_route(Packet) ->
[] -> [] ->
case Packet of case Packet of
#message{type = T} when T == chat; T == normal; #message{type = T} when T == chat; T == normal;
T == headline; T == groupchat -> T == headline ->
route_message(Packet); route_message(Packet);
#presence{} -> #presence{} ->
?DEBUG("dropping presence to unavailable resource:~n~s", ?DEBUG("dropping presence to unavailable resource:~n~s",

View File

@ -410,6 +410,7 @@ message_iterator(Config) ->
Els <- AllEls], Els <- AllEls],
lists:partition( lists:partition(
fun(#message{type = error}) -> true; fun(#message{type = error}) -> true;
(#message{type = groupchat}) -> false;
(#message{sub_els = [#offline{}|_]}) -> false; (#message{sub_els = [#offline{}|_]}) -> false;
(#message{sub_els = [_, #xevent{id = I}]}) when I /= undefined -> false; (#message{sub_els = [_, #xevent{id = I}]}) when I /= undefined -> false;
(#message{sub_els = [#xevent{id = I}]}) when I /= undefined -> false; (#message{sub_els = [#xevent{id = I}]}) when I /= undefined -> false;