mirror of
https://github.com/processone/ejabberd.git
synced 2024-12-22 17:28:25 +01:00
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.
This commit is contained in:
parent
4e7bf9207e
commit
3d434cfcef
@ -758,6 +758,10 @@ get_subscribed_rooms(Host, User) ->
|
|||||||
ServerHost = ejabberd_router:host_of_route(Host),
|
ServerHost = ejabberd_router:host_of_route(Host),
|
||||||
get_subscribed_rooms(ServerHost, Host, User).
|
get_subscribed_rooms(ServerHost, Host, User).
|
||||||
|
|
||||||
|
-record(subscriber, {jid :: jid(),
|
||||||
|
nick = <<>> :: binary(),
|
||||||
|
nodes = [] :: [binary()]}).
|
||||||
|
|
||||||
-spec get_subscribed_rooms(binary(), binary(), jid()) ->
|
-spec get_subscribed_rooms(binary(), binary(), jid()) ->
|
||||||
{ok, [{jid(), [binary()]}]} | {error, any()}.
|
{ok, [{jid(), [binary()]}]} | {error, any()}.
|
||||||
get_subscribed_rooms(ServerHost, Host, From) ->
|
get_subscribed_rooms(ServerHost, Host, From) ->
|
||||||
@ -768,7 +772,15 @@ get_subscribed_rooms(ServerHost, Host, From) ->
|
|||||||
false ->
|
false ->
|
||||||
Rooms = get_online_rooms(ServerHost, Host),
|
Rooms = get_online_rooms(ServerHost, Host),
|
||||||
{ok, lists:flatmap(
|
{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(
|
case p1_fsm:sync_send_all_state_event(
|
||||||
Pid, {is_subscribed, BareFrom}) of
|
Pid, {is_subscribed, BareFrom}) of
|
||||||
{true, Nodes} ->
|
{true, Nodes} ->
|
||||||
|
@ -538,6 +538,7 @@ handle_sync_event({change_config, Config}, _From,
|
|||||||
{reply, {ok, NSD#state.config}, StateName, NSD};
|
{reply, {ok, NSD#state.config}, StateName, NSD};
|
||||||
handle_sync_event({change_state, NewStateData}, _From,
|
handle_sync_event({change_state, NewStateData}, _From,
|
||||||
StateName, _StateData) ->
|
StateName, _StateData) ->
|
||||||
|
erlang:put(muc_subscribers, NewStateData#state.subscribers),
|
||||||
{reply, {ok, NewStateData}, StateName, NewStateData};
|
{reply, {ok, NewStateData}, StateName, NewStateData};
|
||||||
handle_sync_event({process_item_change, Item, UJID}, _From, StateName, StateData) ->
|
handle_sync_event({process_item_change, Item, UJID}, _From, StateName, StateData) ->
|
||||||
case process_item_change(Item, StateData, UJID) of
|
case process_item_change(Item, StateData, UJID) of
|
||||||
@ -4373,6 +4374,7 @@ store_room(StateData) ->
|
|||||||
store_room(StateData, []).
|
store_room(StateData, []).
|
||||||
store_room(StateData, ChangesHints) ->
|
store_room(StateData, ChangesHints) ->
|
||||||
% Let store persistent rooms or on those backends that have get_subscribed_rooms
|
% 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
|
ShouldStore = case (StateData#state.config)#config.persistent of
|
||||||
true ->
|
true ->
|
||||||
true;
|
true;
|
||||||
|
Loading…
Reference in New Issue
Block a user