diff --git a/rebar.config b/rebar.config index d45af48b1..e76482466 100644 --- a/rebar.config +++ b/rebar.config @@ -25,7 +25,7 @@ {fast_tls, ".*", {git, "https://github.com/processone/fast_tls", {tag, "1.0.23"}}}, {stringprep, ".*", {git, "https://github.com/processone/stringprep", {tag, "1.0.12"}}}, {fast_xml, ".*", {git, "https://github.com/processone/fast_xml", {tag, "1.1.32"}}}, - {xmpp, ".*", {git, "https://github.com/processone/xmpp", "8bf26b9e208bd0059cd8fd4e6593d88548c136cf"}}, + {xmpp, ".*", {git, "https://github.com/processone/xmpp", "305e9c3"}}, {fast_yaml, ".*", {git, "https://github.com/processone/fast_yaml", {tag, "1.0.15"}}}, {jiffy, ".*", {git, "https://github.com/davisp/jiffy", {tag, "0.14.8"}}}, {p1_oauth2, ".*", {git, "https://github.com/processone/p1_oauth2", {tag, "0.6.3"}}}, diff --git a/src/mod_muc.erl b/src/mod_muc.erl index 6b53e38d9..3024400ac 100644 --- a/src/mod_muc.erl +++ b/src/mod_muc.erl @@ -106,7 +106,7 @@ -callback unregister_online_user(binary(), ljid(), binary(), binary()) -> any(). -callback count_online_rooms_by_user(binary(), binary(), binary()) -> non_neg_integer(). -callback get_online_rooms_by_user(binary(), binary(), binary()) -> [{binary(), binary()}]. --callback get_subscribed_rooms(binary(), binary(), jid()) -> [ljid()] | []. +-callback get_subscribed_rooms(binary(), binary(), jid()) -> [{ljid(), [binary()]}] | []. %%==================================================================== %% API @@ -614,8 +614,8 @@ process_mucsub(#iq{type = get, from = From, to = To, sub_els = [#muc_subscriptions{}]} = IQ) -> Host = To#jid.lserver, ServerHost = ejabberd_router:host_of_route(Host), - RoomJIDs = get_subscribed_rooms(ServerHost, Host, From), - xmpp:make_iq_result(IQ, #muc_subscriptions{list = RoomJIDs}); + Subs = get_subscribed_rooms(ServerHost, Host, From), + xmpp:make_iq_result(IQ, #muc_subscriptions{list = Subs}); process_mucsub(#iq{lang = Lang} = IQ) -> Txt = <<"No module is handling this query">>, xmpp:make_error(IQ, xmpp:err_service_unavailable(Txt, Lang)). @@ -745,14 +745,15 @@ get_subscribed_rooms(ServerHost, Host, From) -> lists:flatmap( fun({Name, _, Pid}) -> case p1_fsm:sync_send_all_state_event(Pid, {is_subscribed, BareFrom}) of - true -> [jid:make(Name, Host)]; + {true, Nodes} -> + [#muc_subscription{jid = jid:make(Name, Host), events = Nodes}]; false -> [] end; (_) -> [] end, Rooms); V -> - V + [#muc_subscription{jid = Jid, events = Nodes} || {Jid, Nodes} <- V] end. get_nick(ServerHost, Host, From) -> diff --git a/src/mod_muc_room.erl b/src/mod_muc_room.erl index 33c58e416..88bf4f099 100644 --- a/src/mod_muc_room.erl +++ b/src/mod_muc_room.erl @@ -586,7 +586,12 @@ handle_sync_event({muc_unsubscribe, From}, _From, StateName, StateData) -> {reply, {error, get_error_text(Err)}, StateName, StateData} end; handle_sync_event({is_subscribed, From}, _From, StateName, StateData) -> - IsSubs = ?DICT:is_key(jid:split(From), StateData#state.subscribers), + IsSubs = case (?DICT):find(jid:split(From), StateData#state.subscribers) of + {ok, #subscriber{nodes = Nodes}} -> + {true, Nodes}; + error -> + false + end, {reply, IsSubs, StateName, StateData}; handle_sync_event(_Event, _From, StateName, StateData) -> @@ -4090,11 +4095,11 @@ process_iq_mucsub(From, #iq{type = get, lang = Lang, FAffiliation = get_affiliation(From, StateData), FRole = get_role(From, StateData), if FRole == moderator; FAffiliation == owner; FAffiliation == admin -> - JIDs = dict:fold( - fun(_, #subscriber{jid = J}, Acc) -> - [J|Acc] + Subs = dict:fold( + fun(_, #subscriber{jid = J, nodes = Nodes}, Acc) -> + [#muc_subscription{jid = J, events = Nodes}|Acc] end, [], StateData#state.subscribers), - {result, #muc_subscriptions{list = JIDs}, StateData}; + {result, #muc_subscriptions{list = Subs}, StateData}; true -> Txt = <<"Moderator privileges required">>, {error, xmpp:err_forbidden(Txt, Lang)} diff --git a/src/mod_muc_sql.erl b/src/mod_muc_sql.erl index d078b64f1..e92b4bc54 100644 --- a/src/mod_muc_sql.erl +++ b/src/mod_muc_sql.erl @@ -411,10 +411,10 @@ get_subscribed_rooms(LServer, Host, Jid) -> JidS = jid:encode(Jid), case catch ejabberd_sql:sql_query( LServer, - ?SQL("select @(room)s from muc_room_subscribers where jid=%(JidS)s" + ?SQL("select @(room)s, @(nodes)s from muc_room_subscribers where jid=%(JidS)s" " and host=%(Host)s")) of {selected, Subs} -> - [jid:make(Room, Host, <<>>) || {Room} <- Subs]; + [{jid:make(Room, Host, <<>>), ejabberd_sql:decode_term(Nodes)} || {Room, Nodes} <- Subs]; _Error -> [] end.