aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorPaweł Chmielowski <pchmielowski@process-one.net>2021-01-26 11:13:23 +0100
committerPaweł Chmielowski <pchmielowski@process-one.net>2021-01-26 11:13:23 +0100
commitb977320091da79dff2342bb0cb2c43206eb96d70 (patch)
tree8bad316d72c4522378f100d07b63805680f1017b /src
parentRename function arguments (diff)
Don't fetch subscribers list in room_unused_*
Diffstat (limited to 'src')
-rw-r--r--src/mod_muc_admin.erl9
-rw-r--r--src/mod_muc_sql.erl18
2 files changed, 25 insertions, 2 deletions
diff --git a/src/mod_muc_admin.erl b/src/mod_muc_admin.erl
index e35b19419..afe349e0c 100644
--- a/src/mod_muc_admin.erl
+++ b/src/mod_muc_admin.erl
@@ -852,6 +852,13 @@ get_all_rooms(Host) ->
end, #{}, OnlineRooms),
Mod = gen_mod:db_mod(ServerHost, mod_muc),
+ DbRooms =
+ case erlang:function_exported(Mod, get_rooms_without_subscribers, 2) of
+ true ->
+ Mod:get_rooms_without_subscribers(ServerHost, Host);
+ _ ->
+ Mod:get_rooms(ServerHost, Host)
+ end,
StoredRooms = lists:filtermap(
fun(#muc_room{name_host = {Room, _}, opts = Opts}) ->
case maps:is_key(Room, OnlineMap) of
@@ -860,7 +867,7 @@ get_all_rooms(Host) ->
_ ->
{true, {Room, Host, ServerHost, Opts}}
end
- end, Mod:get_rooms(ServerHost, Host)),
+ end, DbRooms),
OnlineRooms ++ StoredRooms.
get_room_config(Room_pid) ->
diff --git a/src/mod_muc_sql.erl b/src/mod_muc_sql.erl
index 94f969d73..1ffaac955 100644
--- a/src/mod_muc_sql.erl
+++ b/src/mod_muc_sql.erl
@@ -36,7 +36,7 @@
get_online_rooms/3, count_online_rooms/2, rsm_supported/0,
register_online_user/4, unregister_online_user/4,
count_online_rooms_by_user/3, get_online_rooms_by_user/3,
- get_subscribed_rooms/3]).
+ get_subscribed_rooms/3, get_rooms_without_subscribers/2]).
-export([set_affiliation/6, set_affiliations/4, get_affiliation/5,
get_affiliations/3, search_affiliation/4]).
@@ -155,6 +155,22 @@ can_use_nick(LServer, Host, JID, Nick) ->
_ -> true
end.
+get_rooms_without_subscribers(LServer, Host) ->
+ case catch ejabberd_sql:sql_query(
+ LServer,
+ ?SQL("select @(name)s, @(opts)s from muc_room"
+ " where host=%(Host)s")) of
+ {selected, RoomOpts} ->
+ lists:map(
+ fun({Room, Opts}) ->
+ OptsD = ejabberd_sql:decode_term(Opts),
+ #muc_room{name_host = {Room, Host},
+ opts = mod_muc:opts_to_binary(OptsD)}
+ end, RoomOpts);
+ _Err ->
+ []
+ end.
+
get_rooms(LServer, Host) ->
case catch ejabberd_sql:sql_query(
LServer,