mirror of
https://github.com/processone/ejabberd.git
synced 2024-11-20 16:15:59 +01:00
Merge pull request #1664 from weiss/fix-routing
Fix routing of groupchat and headline messages
This commit is contained in:
commit
cf784772c9
@ -177,7 +177,8 @@ check_in_subscription(Acc, User, Server, _JID, _Type, _Reason) ->
|
|||||||
|
|
||||||
-spec bounce_offline_message({bounce, message()} | any()) -> any().
|
-spec bounce_offline_message({bounce, message()} | any()) -> any().
|
||||||
|
|
||||||
bounce_offline_message({bounce, Packet} = Acc) ->
|
bounce_offline_message({bounce, #message{type = T} = Packet} = Acc)
|
||||||
|
when T == chat; T == groupchat; T == normal ->
|
||||||
Lang = xmpp:get_lang(Packet),
|
Lang = xmpp:get_lang(Packet),
|
||||||
Txt = <<"User session not found">>,
|
Txt = <<"User session not found">>,
|
||||||
Err = xmpp:err_service_unavailable(Txt, Lang),
|
Err = xmpp:err_service_unavailable(Txt, Lang),
|
||||||
@ -553,7 +554,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),
|
||||||
@ -572,11 +573,13 @@ do_route(Packet) ->
|
|||||||
case online(Mod:get_sessions(LUser, LServer, LResource)) of
|
case online(Mod:get_sessions(LUser, LServer, LResource)) of
|
||||||
[] ->
|
[] ->
|
||||||
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 ->
|
|
||||||
route_message(Packet);
|
route_message(Packet);
|
||||||
|
#message{type = T} when T == headline ->
|
||||||
|
?DEBUG("dropping headline to unavailable resource:~n~s",
|
||||||
|
[xmpp:pp(Packet)]);
|
||||||
#presence{} ->
|
#presence{} ->
|
||||||
?DEBUG("dropping presence to unavalable resource:~n~s",
|
?DEBUG("dropping presence to unavailable resource:~n~s",
|
||||||
[xmpp:pp(Packet)]);
|
[xmpp:pp(Packet)]);
|
||||||
_ ->
|
_ ->
|
||||||
Lang = xmpp:get_lang(Packet),
|
Lang = xmpp:get_lang(Packet),
|
||||||
|
@ -197,7 +197,9 @@ send_all_master(Config) ->
|
|||||||
Acc + 1
|
Acc + 1
|
||||||
end, 0, Deliver),
|
end, 0, Deliver),
|
||||||
lists:foreach(
|
lists:foreach(
|
||||||
fun(Msg) ->
|
fun(#message{type = headline} = Msg) ->
|
||||||
|
send(Config, Msg#message{to = BarePeer});
|
||||||
|
(Msg) ->
|
||||||
#message{type = error} = Err =
|
#message{type = error} = Err =
|
||||||
send_recv(Config, Msg#message{to = BarePeer}),
|
send_recv(Config, Msg#message{to = BarePeer}),
|
||||||
#stanza_error{reason = 'service-unavailable'} = xmpp:get_error(Err)
|
#stanza_error{reason = 'service-unavailable'} = xmpp:get_error(Err)
|
||||||
@ -410,6 +412,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;
|
||||||
|
Loading…
Reference in New Issue
Block a user