Reapply multicast patch to stock ejabberd files

This commit is contained in:
Badlop 2014-11-12 17:50:40 +01:00
parent 632c05e700
commit 2589d6ec6f
3 changed files with 33 additions and 33 deletions

View File

@ -2187,14 +2187,16 @@ try_roster_subscribe(Type, User, Server, From, To, Packet, StateData) ->
presence_broadcast(StateData, From, JIDSet, Packet) ->
JIDs = ?SETS:to_list(JIDSet),
JIDs2 = format_and_check_privacy(From, StateData, Packet, JIDs, out),
send_multiple(StateData, From, JIDs2, Packet).
Server = StateData#state.server,
send_multiple(From, Server, JIDs2, Packet).
%% Send presence when updating presence
presence_broadcast_to_trusted(StateData, From, Trusted, JIDSet, Packet) ->
JIDs = ?SETS:to_list(JIDSet),
JIDs_trusted = [JID || JID <- JIDs, ?SETS:is_element(JID, Trusted)],
JIDs2 = format_and_check_privacy(From, StateData, Packet, JIDs_trusted, out),
send_multiple(StateData, From, JIDs2, Packet).
Server = StateData#state.server,
send_multiple(From, Server, JIDs2, Packet).
%% Send presence when connecting
presence_broadcast_first(From, StateData, Packet) ->
@ -2206,7 +2208,7 @@ presence_broadcast_first(From, StateData, Packet) ->
PacketProbe = #xmlel{name = <<"presence">>, attrs = [{<<"type">>,<<"probe">>}], children = []},
JIDs2Probe = format_and_check_privacy(From, StateData, PacketProbe, JIDsProbe, out),
Server = StateData#state.server,
send_multiple(StateData, From, JIDs2Probe, PacketProbe),
send_multiple(From, Server, JIDs2Probe, PacketProbe),
{As, JIDs} =
?SETS:fold(
fun(JID, {A, JID_list}) ->
@ -2215,8 +2217,7 @@ presence_broadcast_first(From, StateData, Packet) ->
{StateData#state.pres_a, []},
StateData#state.pres_f),
JIDs2 = format_and_check_privacy(From, StateData, Packet, JIDs, out),
Server = StateData#state.server,
send_multiple(StateData, From, JIDs2, Packet),
send_multiple(From, Server, JIDs2, Packet),
StateData#state{pres_a = As}.
format_and_check_privacy(From, StateData, Packet, JIDs, Dir) ->
@ -2237,16 +2238,8 @@ format_and_check_privacy(From, StateData, Packet, JIDs, Dir) ->
end,
FJIDs).
send_multiple(StateData, From, JIDs, Packet) ->
lists:foreach(
fun(JID) ->
case privacy_check_packet(StateData, From, JID, Packet, out) of
deny ->
ok;
allow ->
ejabberd_router:route(From, JID, Packet)
end
end, JIDs).
send_multiple(From, Server, JIDs, Packet) ->
ejabberd_router_multicast:route_multicast(From, Server, JIDs, Packet).
remove_element(E, Set) ->
case (?SETS):is_element(E, Set) of

View File

@ -62,6 +62,13 @@ init([]) ->
brutal_kill,
worker,
[ejabberd_router]},
Router_multicast =
{ejabberd_router_multicast,
{ejabberd_router_multicast, start_link, []},
permanent,
brutal_kill,
worker,
[ejabberd_router_multicast]},
SM =
{ejabberd_sm,
{ejabberd_sm, start_link, []},
@ -173,6 +180,7 @@ init([]) ->
NodeGroups,
SystemMonitor,
Router,
Router_multicast,
SM,
S2S,
Local,

View File

@ -681,14 +681,11 @@ handle_event({service_message, Msg}, _StateName,
children =
[#xmlel{name = <<"body">>, attrs = [],
children = [{xmlcdata, Msg}]}]},
lists:foreach(
fun({_LJID, Info}) ->
ejabberd_router:route(
send_multiple(
StateData#state.jid,
Info#user.jid,
MessagePkt)
end,
?DICT:to_list(StateData#state.users)),
StateData#state.server_host,
StateData#state.users,
MessagePkt),
NSD = add_message_to_history(<<"">>,
StateData#state.jid, MessagePkt, StateData),
{next_state, normal_state, NSD};
@ -942,16 +939,11 @@ process_groupchat_message(From,
end,
case IsAllowed of
true ->
lists:foreach(
fun({_LJID, Info}) ->
ejabberd_router:route(
jlib:jid_replace_resource(
StateData#state.jid,
FromNick),
Info#user.jid,
Packet)
end,
?DICT:to_list(StateData#state.users)),
send_multiple(
jlib:jid_replace_resource(StateData#state.jid, FromNick),
StateData#state.server_host,
StateData#state.users,
Packet),
NewStateData2 = case has_body_or_subject(Packet) of
true ->
add_message_to_history(FromNick, From,
@ -4525,3 +4517,10 @@ has_body_or_subject(Packet) ->
(#xmlel{name = <<"subject">>}) -> false;
(_) -> true
end, Packet#xmlel.children).
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% Multicast
send_multiple(From, Server, Users, Packet) ->
JIDs = [ User#user.jid || {_, User} <- ?DICT:to_list(Users)],
ejabberd_router_multicast:route_multicast(From, Server, JIDs, Packet).