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

Use multicast in MUC groupchat messages (EJAB-266)

This commit is contained in:
Badlop 2010-05-19 23:57:34 +02:00
parent 8935da5b5c
commit a4cf03dbf0

View File

@ -567,14 +567,11 @@ handle_event({service_message, Msg}, _StateName, StateData) ->
attrs = [?XMLATTR('type', <<"groupchat">>)], attrs = [?XMLATTR('type', <<"groupchat">>)],
children = [#xmlel{name = 'body', children = [#xmlel{name = 'body',
children = [#xmlcdata{cdata = Msg}]}]}, children = [#xmlcdata{cdata = Msg}]}]},
lists:foreach( send_multiple(
fun({_LJID, Info}) -> StateData#state.jid,
ejabberd_router:route( StateData#state.server_host,
StateData#state.jid, StateData#state.users,
Info#user.jid, MessagePkt),
MessagePkt)
end,
?DICT:to_list(StateData#state.users)),
NSD = add_message_to_history("", NSD = add_message_to_history("",
StateData#state.jid, StateData#state.jid,
MessagePkt, MessagePkt,
@ -822,16 +819,11 @@ process_groupchat_message(From, #xmlel{name = 'message'} = Packet,
end, end,
case IsAllowed of case IsAllowed of
true -> true ->
lists:foreach( send_multiple(
fun({_LJID, Info}) -> jid_replace_resource(StateData#state.jid, FromNick),
ejabberd_router:route( StateData#state.server_host,
jid_replace_resource( StateData#state.users,
StateData#state.jid, Packet),
FromNick),
Info#user.jid,
Packet)
end,
?DICT:to_list(StateData#state.users)),
NewStateData2 = NewStateData2 =
add_message_to_history(FromNick, add_message_to_history(FromNick,
From, From,
@ -3710,9 +3702,12 @@ tab_count_user(JID) ->
0 0
end. end.
jid_replace_resource(JID, Resource) -> jid_replace_resource(JID, Resource) ->
exmpp_jid:full(JID, Resource). exmpp_jid:full(JID, Resource).
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% 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).