aboutsummaryrefslogtreecommitdiff
path: root/src/mod_muc_admin.erl
diff options
context:
space:
mode:
Diffstat (limited to 'src/mod_muc_admin.erl')
-rw-r--r--src/mod_muc_admin.erl23
1 files changed, 14 insertions, 9 deletions
diff --git a/src/mod_muc_admin.erl b/src/mod_muc_admin.erl
index ac2d887fe..0015eb30a 100644
--- a/src/mod_muc_admin.erl
+++ b/src/mod_muc_admin.erl
@@ -5,7 +5,7 @@
%%% Created : 8 Sep 2007 by Badlop <badlop@ono.com>
%%%
%%%
-%%% ejabberd, Copyright (C) 2002-2021 ProcessOne
+%%% ejabberd, Copyright (C) 2002-2022 ProcessOne
%%%
%%% This program is free software; you can redistribute it and/or
%%% modify it under the terms of the GNU General Public License as
@@ -858,7 +858,7 @@ rooms_report(Method, Action, Service, Days) ->
muc_unused(Method, Action, Service, Last_allowed) ->
%% Get all required info about all existing rooms
- Rooms_all = get_all_rooms(Service),
+ Rooms_all = get_all_rooms(Service, erlang:system_time(microsecond) - Last_allowed*24*60*60*1000),
%% Decide which ones pass the requirements
Rooms_pass = decide_rooms(Method, Rooms_all, Last_allowed),
@@ -883,14 +883,14 @@ get_online_rooms(ServiceArg) ->
|| {RoomName, RoomHost, Pid} <- mod_muc:get_online_rooms(Host)]
end, Hosts).
-get_all_rooms(ServiceArg) ->
+get_all_rooms(ServiceArg, Timestamp) ->
Hosts = find_services(ServiceArg),
lists:flatmap(
fun(Host) ->
- get_all_rooms2(Host)
+ get_all_rooms2(Host, Timestamp)
end, Hosts).
-get_all_rooms2(Host) ->
+get_all_rooms2(Host, Timestamp) ->
ServerHost = ejabberd_router:host_of_route(Host),
OnlineRooms = get_online_rooms(Host),
OnlineMap = lists:foldl(
@@ -900,8 +900,11 @@ get_all_rooms2(Host) ->
Mod = gen_mod:db_mod(ServerHost, mod_muc),
DbRooms =
- case erlang:function_exported(Mod, get_rooms_without_subscribers, 2) of
- true ->
+ case {erlang:function_exported(Mod, get_rooms_without_subscribers, 2),
+ erlang:function_exported(Mod, get_hibernated_rooms_older_than, 3)} of
+ {_, true} ->
+ Mod:get_hibernated_rooms_older_than(ServerHost, Host, Timestamp);
+ {true, _} ->
Mod:get_rooms_without_subscribers(ServerHost, Host);
_ ->
Mod:get_rooms(ServerHost, Host)
@@ -956,6 +959,8 @@ decide_room(unused, {_Room_name, _Host, ServerHost, Room_pid}, Last_allowed) ->
case lists:keyfind(hibernation_time, 1, Opts) of
false ->
{NodeStartTime, 0};
+ {_, undefined} ->
+ {NodeStartTime, 0};
{_, T} ->
{T, 0}
end
@@ -1045,8 +1050,8 @@ get_room_occupants(Pid) ->
get_room_occupants_number(Room, Host) ->
case get_room_pid(Room, Host) of
Pid when is_pid(Pid )->
- S = get_room_state(Pid),
- maps:size(S#state.users);
+ {ok, #{occupants_number := N}} = mod_muc_room:get_info(Pid),
+ N;
_ ->
throw({error, room_not_found})
end.