diff --git a/src/ejabberd_sm.erl b/src/ejabberd_sm.erl index 755c2e92e..c7e277a8d 100644 --- a/src/ejabberd_sm.erl +++ b/src/ejabberd_sm.erl @@ -455,7 +455,28 @@ recount_session_table(Node) -> %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -do_route(From, To, Packet) -> +do_route(From, To, {broadcast, _} = Packet) -> + case To#jid.lresource of + <<"">> -> + lists:foreach(fun(R) -> + do_route(From, + jlib:jid_replace_resource(To, R), + Packet) + end, + get_user_resources(To#jid.user, To#jid.server)); + _ -> + USR = jlib:jid_tolower(To), + case mnesia:dirty_index_read(session, USR, #session.usr) of + [] -> + ?DEBUG("packet dropped~n", []); + Ss -> + Session = lists:max(Ss), + Pid = element(2, Session#session.sid), + ?DEBUG("sending to process ~p~n", [Pid]), + Pid ! {route, From, To, Packet} + end + end; +do_route(From, To, #xmlel{} = Packet) -> ?DEBUG("session manager~n\tfrom ~p~n\tto ~p~n\tpacket " "~P~n", [From, To, Packet, 8]), diff --git a/src/mod_privacy.erl b/src/mod_privacy.erl index 4dbf608c6..ab77a30d3 100644 --- a/src/mod_privacy.erl +++ b/src/mod_privacy.erl @@ -494,11 +494,11 @@ process_list_set(LUser, LServer, {value, Name}, Els) -> ejabberd_sm:route(jlib:make_jid(LUser, LServer, <<"">>), jlib:make_jid(LUser, LServer, <<"">>), - #xmlel{name = <<"broadcast">>, children = - [{privacy_list, - #userlist{name = Name, - list = []}, - Name}]}), + {broadcast, + {privacy_list, + #userlist{name = Name, + list = []}, + Name}}), {result, []}; _ -> {error, ?ERR_INTERNAL_SERVER_ERROR} end; @@ -511,12 +511,12 @@ process_list_set(LUser, LServer, {value, Name}, Els) -> ejabberd_sm:route(jlib:make_jid(LUser, LServer, <<"">>), jlib:make_jid(LUser, LServer, <<"">>), - #xmlel{name = <<"broadcast">>, children = - [{privacy_list, - #userlist{name = Name, - list = List, - needdb = NeedDb}, - Name}]}), + {broadcast, + {privacy_list, + #userlist{name = Name, + list = List, + needdb = NeedDb}, + Name}}), {result, []}; _ -> {error, ?ERR_INTERNAL_SERVER_ERROR} end