mirror of
https://github.com/processone/ejabberd.git
synced 2024-11-22 16:20:52 +01:00
This commit is contained in:
parent
f721374321
commit
d5841785e1
@ -1050,8 +1050,8 @@ get_room_occupants(Pid) ->
|
|||||||
get_room_occupants_number(Room, Host) ->
|
get_room_occupants_number(Room, Host) ->
|
||||||
case get_room_pid(Room, Host) of
|
case get_room_pid(Room, Host) of
|
||||||
Pid when is_pid(Pid )->
|
Pid when is_pid(Pid )->
|
||||||
S = get_room_state(Pid),
|
{ok, #{occupants_number := N}} = mod_muc_room:get_info(Pid),
|
||||||
maps:size(S#state.users);
|
N;
|
||||||
_ ->
|
_ ->
|
||||||
throw({error, room_not_found})
|
throw({error, room_not_found})
|
||||||
end.
|
end.
|
||||||
|
@ -49,6 +49,7 @@
|
|||||||
get_config/1,
|
get_config/1,
|
||||||
set_config/2,
|
set_config/2,
|
||||||
get_state/1,
|
get_state/1,
|
||||||
|
get_info/1,
|
||||||
change_item/5,
|
change_item/5,
|
||||||
change_item_async/5,
|
change_item_async/5,
|
||||||
config_reloaded/1,
|
config_reloaded/1,
|
||||||
@ -217,6 +218,17 @@ get_state(Pid) ->
|
|||||||
{error, notfound}
|
{error, notfound}
|
||||||
end.
|
end.
|
||||||
|
|
||||||
|
-spec get_info(pid()) -> {ok, #{occupants_number => integer()}} |
|
||||||
|
{error, notfound | timeout}.
|
||||||
|
get_info(Pid) ->
|
||||||
|
try
|
||||||
|
{ok, p1_fsm:sync_send_all_state_event(Pid, get_info)}
|
||||||
|
catch _:{timeout, {p1_fsm, _, _}} ->
|
||||||
|
{error, timeout};
|
||||||
|
_:{_, {p1_fsm, _, _}} ->
|
||||||
|
{error, notfound}
|
||||||
|
end.
|
||||||
|
|
||||||
-spec subscribe(pid(), jid(), binary(), [binary()]) -> {ok, [binary()]} | {error, binary()}.
|
-spec subscribe(pid(), jid(), binary(), [binary()]) -> {ok, [binary()]} | {error, binary()}.
|
||||||
subscribe(Pid, JID, Nick, Nodes) ->
|
subscribe(Pid, JID, Nick, Nodes) ->
|
||||||
try p1_fsm:sync_send_all_state_event(Pid, {muc_subscribe, JID, Nick, Nodes})
|
try p1_fsm:sync_send_all_state_event(Pid, {muc_subscribe, JID, Nick, Nodes})
|
||||||
@ -721,6 +733,10 @@ handle_sync_event(get_config, _From, StateName,
|
|||||||
handle_sync_event(get_state, _From, StateName,
|
handle_sync_event(get_state, _From, StateName,
|
||||||
StateData) ->
|
StateData) ->
|
||||||
{reply, {ok, StateData}, StateName, StateData};
|
{reply, {ok, StateData}, StateName, StateData};
|
||||||
|
handle_sync_event(get_info, _From, StateName,
|
||||||
|
StateData) ->
|
||||||
|
Result = #{occupants_number => maps:size(StateData#state.users)},
|
||||||
|
{reply, Result, StateName, StateData};
|
||||||
handle_sync_event({change_config, Config}, _From,
|
handle_sync_event({change_config, Config}, _From,
|
||||||
StateName, StateData) ->
|
StateName, StateData) ->
|
||||||
{result, undefined, NSD} = change_config(Config, StateData),
|
{result, undefined, NSD} = change_config(Config, StateData),
|
||||||
|
Loading…
Reference in New Issue
Block a user