diff options
author | Paweł Chmielowski <pchmielowski@process-one.net> | 2021-03-03 11:30:43 +0100 |
---|---|---|
committer | Paweł Chmielowski <pchmielowski@process-one.net> | 2021-03-03 11:32:05 +0100 |
commit | ca5d5f3b4caf64be6de272e33617364c32465e6d (patch) | |
tree | bf86d9d7ef2bc3f70b4d3afd137575b63e861972 /src/mod_muc_sql.erl | |
parent | Merge pull request #3507 from slezakattack/master (diff) |
Use monitors to track muc rooms
This should prevent keeping rooms that were hard killed from in
online table.
Diffstat (limited to 'src/mod_muc_sql.erl')
-rw-r--r-- | src/mod_muc_sql.erl | 18 |
1 files changed, 17 insertions, 1 deletions
diff --git a/src/mod_muc_sql.erl b/src/mod_muc_sql.erl index c9115492..569cfac4 100644 --- a/src/mod_muc_sql.erl +++ b/src/mod_muc_sql.erl @@ -36,7 +36,8 @@ 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_rooms_without_subscribers/2]). + get_subscribed_rooms/3, get_rooms_without_subscribers/2, + find_online_room_by_pid/2]). -export([set_affiliation/6, set_affiliations/4, get_affiliation/5, get_affiliations/3, search_affiliation/4]). @@ -306,6 +307,21 @@ find_online_room(ServerHost, Room, Host) -> error end. +find_online_room_by_pid(ServerHost, Pid) -> + PidS = misc:encode_pid(Pid), + NodeS = erlang:atom_to_binary(node(Pid), latin1), + case ejabberd_sql:sql_query( + ServerHost, + ?SQL("select @(name)s, @(host)s from muc_online_room where " + "node=%(NodeS)s and pid=%(PidS)s")) of + {selected, [{Room, Host}]} -> + {ok, Room, Host}; + {selected, []} -> + error; + _Err -> + error + end. + count_online_rooms(ServerHost, Host) -> case ejabberd_sql:sql_query( ServerHost, |