mirror of
https://github.com/processone/ejabberd.git
synced 2024-12-20 17:27:00 +01:00
Revert "New option tombstone_expiry locks recent room creation after destroy (#2546)"
This reverts commit efb4fd0d10
.
This commit is contained in:
parent
dd888f90ec
commit
d5c1174385
@ -435,7 +435,7 @@ do_route1(Host, ServerHost, Access, HistorySize, RoomShaper,
|
||||
{_AccessRoute, AccessCreate, _AccessAdmin, _AccessPersistent} = Access,
|
||||
{Room, _, Nick} = jid:tolower(To),
|
||||
RMod = gen_mod:ram_db_mod(ServerHost, ?MODULE),
|
||||
case find_online_available_room(RMod, ServerHost, Room, Host) of
|
||||
case RMod:find_online_room(ServerHost, Room, Host) of
|
||||
error ->
|
||||
case is_create_request(Packet) of
|
||||
true ->
|
||||
@ -463,38 +463,12 @@ do_route1(Host, ServerHost, Access, HistorySize, RoomShaper,
|
||||
Err = xmpp:err_item_not_found(ErrText, Lang),
|
||||
ejabberd_router:route_error(Packet, Err)
|
||||
end;
|
||||
locked_room ->
|
||||
Lang = xmpp:get_lang(Packet),
|
||||
ErrText = <<"Conference room was destroyed">>,
|
||||
Err = xmpp:err_item_not_found(ErrText, Lang),
|
||||
ejabberd_router:route_error(Packet, Err);
|
||||
{ok, Pid} ->
|
||||
?DEBUG("MUC: send to process ~p~n", [Pid]),
|
||||
mod_muc_room:route(Pid, Packet),
|
||||
ok
|
||||
end.
|
||||
|
||||
find_online_available_room(RMod, ServerHost, Room, Host) ->
|
||||
case RMod:find_online_room(ServerHost, Room, Host) of
|
||||
error ->
|
||||
error;
|
||||
{ok, Pid} ->
|
||||
check_tombstone(Pid)
|
||||
end.
|
||||
|
||||
-define(TOMBSTONE_REASON, <<"Expiring tombstone">>).
|
||||
|
||||
check_tombstone(Pid) ->
|
||||
case p1_fsm:sync_send_all_state_event(Pid, check_tombstone) of
|
||||
not_tombstone ->
|
||||
{ok, Pid};
|
||||
locked ->
|
||||
locked_room;
|
||||
expired ->
|
||||
p1_fsm:send_all_state_event(Pid, {destroy, ?TOMBSTONE_REASON}),
|
||||
error
|
||||
end.
|
||||
|
||||
-spec process_vcard(iq()) -> iq().
|
||||
process_vcard(#iq{type = get, lang = Lang, sub_els = [#vcard_temp{}]} = IQ) ->
|
||||
xmpp:make_iq_result(
|
||||
@ -949,8 +923,6 @@ mod_opt_type(min_presence_interval) ->
|
||||
fun (I) when is_number(I), I >= 0 -> I end;
|
||||
mod_opt_type(room_shaper) ->
|
||||
fun (A) when is_atom(A) -> A end;
|
||||
mod_opt_type(tombstone_expiry) ->
|
||||
fun (I) when is_integer(I) -> I end;
|
||||
mod_opt_type(user_message_shaper) ->
|
||||
fun (A) when is_atom(A) -> A end;
|
||||
mod_opt_type(user_presence_shaper) ->
|
||||
@ -1040,7 +1012,6 @@ mod_options(Host) ->
|
||||
{queue_type, ejabberd_config:default_queue_type(Host)},
|
||||
{regexp_room_id, <<"">>},
|
||||
{room_shaper, none},
|
||||
{tombstone_expiry, 0},
|
||||
{user_message_shaper, none},
|
||||
{user_presence_shaper, none},
|
||||
{default_room_options,
|
||||
|
@ -533,9 +533,6 @@ handle_sync_event({change_config, Config}, _From,
|
||||
handle_sync_event({change_state, NewStateData}, _From,
|
||||
StateName, _StateData) ->
|
||||
{reply, {ok, NewStateData}, StateName, NewStateData};
|
||||
handle_sync_event(check_tombstone, _From,
|
||||
StateName, StateData) ->
|
||||
{reply, check_tombstone(StateData), StateName, StateData};
|
||||
handle_sync_event({process_item_change, Item, UJID}, _From, StateName, StateData) ->
|
||||
case process_item_change(Item, StateData, UJID) of
|
||||
{error, _} = Err ->
|
||||
@ -3795,52 +3792,11 @@ destroy_room(DEl, StateData) ->
|
||||
case (StateData#state.config)#config.persistent of
|
||||
true ->
|
||||
mod_muc:forget_room(StateData#state.server_host,
|
||||
StateData#state.host, StateData#state.room),
|
||||
maybe_create_tombstone(DEl, StateData);
|
||||
StateData#state.host, StateData#state.room);
|
||||
false -> ok
|
||||
end,
|
||||
{result, undefined, stop}.
|
||||
|
||||
-define(TOMBSTONE_NAME, <<"Room tombstone">>).
|
||||
-define(TOMBSTONE_REASON, <<"Expiring tombstone">>).
|
||||
|
||||
maybe_create_tombstone(DEl, StateData) ->
|
||||
case DEl#muc_destroy.reason of
|
||||
?TOMBSTONE_REASON ->
|
||||
ok;
|
||||
_ ->
|
||||
TombstoneExpiry = gen_mod:get_module_opt(StateData#state.server_host,
|
||||
mod_muc, tombstone_expiry),
|
||||
create_tombstone(TombstoneExpiry, StateData)
|
||||
end.
|
||||
|
||||
create_tombstone(TombstoneExpiry, _) when TombstoneExpiry =< 0 ->
|
||||
ok;
|
||||
create_tombstone(TombstoneExpiry, #state{server_host = Server, host = Host, room = Room}) ->
|
||||
?INFO_MSG("Creating tombstone for room ~s@~s", [Room, Host]),
|
||||
Password = integer_to_binary(misc:now_to_usec(now()) + TombstoneExpiry*1000000),
|
||||
Opts1 = gen_mod:get_module_opt(Server, mod_muc, default_room_options),
|
||||
{_, Opts2} = proplists:split(Opts1, [title, password, persistent, public]),
|
||||
Opts3 = [{title, ?TOMBSTONE_NAME}, {password, Password}, {persistent, true}, {public, false} | Opts2],
|
||||
mod_muc:create_room(
|
||||
Host,
|
||||
Room,
|
||||
jid:make(<<"tombstone">>, <<"">>),
|
||||
<<"">>,
|
||||
Opts3).
|
||||
|
||||
check_tombstone(#state{config = Config}) ->
|
||||
case Config#config.title of
|
||||
?TOMBSTONE_NAME ->
|
||||
case binary_to_integer(Config#config.password) < misc:now_to_usec(now()) of
|
||||
true ->
|
||||
expired;
|
||||
false ->
|
||||
locked
|
||||
end;
|
||||
_ -> not_tombstone
|
||||
end.
|
||||
|
||||
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||
% Disco
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user