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

View File

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

View File

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