25
1
mirror of https://github.com/processone/ejabberd.git synced 2024-11-24 16:23:40 +01:00

Stop empty MUC rooms 30 seconds after creation

This commit is contained in:
Alexey Shchepin 2022-04-21 14:37:01 +03:00
parent 155261f78a
commit 74e86611ab

View File

@ -85,6 +85,7 @@
-define(MUC_HAT_LIST_CMD, <<"p1:hats#list">>).
-define(MAX_HATS_USERS, 100).
-define(MAX_HATS_PER_USER, 10).
-define(CLEAN_ROOM_TIMEOUT, 30000).
%-define(DBGFSM, true).
@ -309,6 +310,8 @@ init([Host, ServerHost, Access, Room, HistorySize,
add_to_log(room_existence, created, State1),
add_to_log(room_existence, started, State1),
ejabberd_hooks:run(start_room, ServerHost, [ServerHost, Room, Host]),
erlang:send_after(?CLEAN_ROOM_TIMEOUT, self(),
close_room_if_temporary_and_empty),
{ok, normal_state, reset_hibernate_timer(State1)};
init([Host, ServerHost, Access, Room, HistorySize, RoomShaper, Opts, QueueType]) ->
process_flag(trap_exit, true),
@ -325,6 +328,8 @@ init([Host, ServerHost, Access, Room, HistorySize, RoomShaper, Opts, QueueType])
add_to_log(room_existence, started, State),
ejabberd_hooks:run(start_room, ServerHost, [ServerHost, Room, Host]),
State1 = cleanup_affiliations(State),
erlang:send_after(?CLEAN_ROOM_TIMEOUT, self(),
close_room_if_temporary_and_empty),
{ok, normal_state, reset_hibernate_timer(State1)}.
normal_state({route, <<"">>,
@ -891,6 +896,8 @@ handle_info({captcha_failed, From}, normal_state,
StateData
end,
{next_state, normal_state, NewState};
handle_info(close_room_if_temporary_and_empty, _StateName, StateData) ->
close_room_if_temporary_and_empty(StateData);
handle_info(shutdown, _StateName, StateData) ->
{stop, shutdown, StateData};
handle_info({iq_reply, #iq{type = Type, sub_els = Els},