diff options
author | Paweł Chmielowski <pchmielowski@process-one.net> | 2019-05-06 19:15:48 +0200 |
---|---|---|
committer | Paweł Chmielowski <pchmielowski@process-one.net> | 2019-05-06 19:15:48 +0200 |
commit | 3d434cfcef3356319f3fdfe94cc34f848ade51c4 (patch) | |
tree | f42a18feceb6c131b6dc625dcdcc9a37a3d59752 /src/mod_muc.erl | |
parent | Do not declare mod_muc as dependency of mod_mam to prevent loop in deps (diff) |
Handle get_subscribed_rooms call from mod_muc_room pid
Previously sometimes we tried to post message to all online rooms, and
if that was called from muc room pid, we were not able to process that
message for that room and send response, and this did lead to timeout.
Diffstat (limited to 'src/mod_muc.erl')
-rw-r--r-- | src/mod_muc.erl | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/src/mod_muc.erl b/src/mod_muc.erl index 76fce1f8e..edc570eed 100644 --- a/src/mod_muc.erl +++ b/src/mod_muc.erl @@ -758,6 +758,10 @@ get_subscribed_rooms(Host, User) -> 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) -> @@ -768,7 +772,15 @@ 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} -> |