ServerHost = ejabberd_router:host_of_route(Host),
get_subscribed_rooms(ServerHost, Host, User).
+-record(subscriber, {jid :: jid(),
+ nick = <<>> :: binary(),
+ nodes = [] :: [binary()]}).
+
-spec get_subscribed_rooms(binary(), binary(), jid()) ->
{ok, [{jid(), [binary()]}]} | {error, any()}.
get_subscribed_rooms(ServerHost, Host, From) ->
false ->
Rooms = get_online_rooms(ServerHost, Host),
{ok, lists:flatmap(
- fun({Name, _, Pid}) ->
+ fun({Name, _, Pid}) when Pid == self() ->
+ USR = jid:split(BareFrom),
+ case erlang:get(muc_subscribers) of
+ #{USR := #subscriber{nodes = Nodes}} ->
+ [{jid:make(Name, Host), Nodes}];
+ _ ->
+ []
+ end;
+ ({Name, _, Pid}) ->
case p1_fsm:sync_send_all_state_event(
Pid, {is_subscribed, BareFrom}) of
{true, Nodes} ->
{reply, {ok, NSD#state.config}, StateName, NSD};
handle_sync_event({change_state, NewStateData}, _From,
StateName, _StateData) ->
+ erlang:put(muc_subscribers, NewStateData#state.subscribers),
{reply, {ok, NewStateData}, StateName, NewStateData};
handle_sync_event({process_item_change, Item, UJID}, _From, StateName, StateData) ->
case process_item_change(Item, StateData, UJID) of
store_room(StateData, []).
store_room(StateData, ChangesHints) ->
% Let store persistent rooms or on those backends that have get_subscribed_rooms
+ erlang:put(muc_subscribers, StateData#state.subscribers),
ShouldStore = case (StateData#state.config)#config.persistent of
true ->
true;