summaryrefslogtreecommitdiff
path: root/src/mod_muc_sql.erl
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/mod_muc_sql.erl
parentRename function arguments (diff)
Don't fetch subscribers list in room_unused_*
Diffstat (limited to 'src/mod_muc_sql.erl')
-rw-r--r--src/mod_muc_sql.erl18
1 files changed, 17 insertions, 1 deletions
diff --git a/src/mod_muc_sql.erl b/src/mod_muc_sql.erl
index 94f969d7..1ffaac95 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,