From 5bcfcf4c5e74638960894fa2e7b9e57dfdfb62f3 Mon Sep 17 00:00:00 2001 From: Badlop Date: Mon, 19 Sep 2016 13:46:01 +0200 Subject: [PATCH] When getting list of subscribed rooms, check all including temporary ones (#1242) --- src/mod_muc.erl | 9 ++++----- src/mod_muc_room.erl | 3 +++ 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/src/mod_muc.erl b/src/mod_muc.erl index 4eb129a87..ad2be4cce 100644 --- a/src/mod_muc.erl +++ b/src/mod_muc.erl @@ -718,13 +718,12 @@ get_vh_rooms(Host, #rsm_in{max=M, direction=Direction, id=I, index=Index})-> index = NewIndex}} end. -get_subscribed_rooms(ServerHost, Host, From) -> - Rooms = get_rooms(ServerHost, Host), +get_subscribed_rooms(_ServerHost, Host1, From) -> + Rooms = get_vh_rooms(Host1), BareFrom = jid:remove_resource(From), lists:flatmap( - fun(#muc_room{name_host = {Name, _}, opts = Opts}) -> - Subscribers = proplists:get_value(subscribers, Opts, []), - case lists:keymember(BareFrom, 1, Subscribers) of + fun(#muc_online_room{name_host = {Name, Host}, pid = Pid}) -> + case gen_fsm:sync_send_all_state_event(Pid, {is_subscribed, BareFrom}) of true -> [jid:make(Name, Host, <<>>)]; false -> [] end; diff --git a/src/mod_muc_room.erl b/src/mod_muc_room.erl index 5aceb94c1..fc2aeebb6 100644 --- a/src/mod_muc_room.erl +++ b/src/mod_muc_room.erl @@ -800,6 +800,9 @@ handle_sync_event({muc_unsubscribe, From}, _From, StateName, StateData) -> {error, Err} -> {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), + {reply, IsSubs, StateName, StateData}; handle_sync_event(_Event, _From, StateName, StateData) -> Reply = ok, {reply, Reply, StateName, StateData}. -- 2.40.0