mirror of
https://github.com/processone/ejabberd.git
synced 2024-11-20 16:15:59 +01:00
Minor improvements to support mod_tombstones
New check_register_user hook in ejabberd_auth.erl to allow blocking account registration when a tombstone exists. Modified room_destroyed hook in mod_muc_room.erl Until now the hook passed as arguments: LServer, Room, Host. Now it passes: LServer, Room, Host, Persistent That new Persistent argument passes the room persistent option, required by mod_tombstones because only persistent rooms should generate a tombstone, temporary ones should not. And the persistent option should not be completely overwritten, as we must still known its real value even when room is being destroyed. mod_tombstones is available in experimental mode in ejabberd-contrib git. Initial feature request: #2546
This commit is contained in:
parent
8be0f8a0b0
commit
71ad7c368d
@ -44,7 +44,7 @@
|
|||||||
allow_visitor_nickchange = true :: boolean(),
|
allow_visitor_nickchange = true :: boolean(),
|
||||||
public = true :: boolean(),
|
public = true :: boolean(),
|
||||||
public_list = true :: boolean(),
|
public_list = true :: boolean(),
|
||||||
persistent = false :: boolean(),
|
persistent = false :: boolean() | {destroying, boolean()},
|
||||||
moderated = true :: boolean(),
|
moderated = true :: boolean(),
|
||||||
captcha_protected = false :: boolean(),
|
captcha_protected = false :: boolean(),
|
||||||
members_by_default = true :: boolean(),
|
members_by_default = true :: boolean(),
|
||||||
|
@ -292,6 +292,8 @@ try_register(User, Server, Password) ->
|
|||||||
{error, exists};
|
{error, exists};
|
||||||
false ->
|
false ->
|
||||||
case ejabberd_router:is_my_host(LServer) of
|
case ejabberd_router:is_my_host(LServer) of
|
||||||
|
true ->
|
||||||
|
case ejabberd_hooks:run_fold(check_register_user, LServer, true, [User, Server, Password]) of
|
||||||
true ->
|
true ->
|
||||||
case lists:foldl(
|
case lists:foldl(
|
||||||
fun(_, ok) ->
|
fun(_, ok) ->
|
||||||
@ -309,6 +311,9 @@ try_register(User, Server, Password) ->
|
|||||||
end;
|
end;
|
||||||
false ->
|
false ->
|
||||||
{error, not_allowed}
|
{error, not_allowed}
|
||||||
|
end;
|
||||||
|
false ->
|
||||||
|
{error, not_allowed}
|
||||||
end
|
end
|
||||||
end;
|
end;
|
||||||
Err ->
|
Err ->
|
||||||
|
@ -1726,7 +1726,7 @@ make_command_raw_value(Name, Request, BaseArguments) ->
|
|||||||
raw_value |
|
raw_value |
|
||||||
raw_and_value} |
|
raw_and_value} |
|
||||||
{input_name_append, [binary()]} |
|
{input_name_append, [binary()]} |
|
||||||
{force_execution, boolean()} |
|
{force_execution, boolean() | undefined} |
|
||||||
{table_options, {PageSize :: integer(), RemainingPath :: [binary()]}} |
|
{table_options, {PageSize :: integer(), RemainingPath :: [binary()]}} |
|
||||||
{result_named, boolean()} |
|
{result_named, boolean()} |
|
||||||
{result_links,
|
{result_links,
|
||||||
@ -1737,7 +1737,7 @@ make_command_raw_value(Name, Request, BaseArguments) ->
|
|||||||
{style, normal | danger}.
|
{style, normal | danger}.
|
||||||
make_command2(Name, Request, BaseArguments, Options) ->
|
make_command2(Name, Request, BaseArguments, Options) ->
|
||||||
Only = proplists:get_value(only, Options, all),
|
Only = proplists:get_value(only, Options, all),
|
||||||
ForceExecution = proplists:get_value(force_execution, Options, false),
|
ForceExecution = proplists:get_value(force_execution, Options, undefined),
|
||||||
InputNameAppend = proplists:get_value(input_name_append, Options, []),
|
InputNameAppend = proplists:get_value(input_name_append, Options, []),
|
||||||
Resultnamed = proplists:get_value(result_named, Options, false),
|
Resultnamed = proplists:get_value(result_named, Options, false),
|
||||||
ResultLinks = proplists:get_value(result_links, Options, []),
|
ResultLinks = proplists:get_value(result_links, Options, []),
|
||||||
@ -1791,6 +1791,8 @@ make_command2(Name,
|
|||||||
case {ForceExecution, ResultFormatApi} of
|
case {ForceExecution, ResultFormatApi} of
|
||||||
{true, _} ->
|
{true, _} ->
|
||||||
auto;
|
auto;
|
||||||
|
{false, _} ->
|
||||||
|
manual;
|
||||||
{_, {_, rescode}} ->
|
{_, {_, rescode}} ->
|
||||||
manual;
|
manual;
|
||||||
{_, {_, restuple}} ->
|
{_, {_, restuple}} ->
|
||||||
|
@ -540,7 +540,7 @@ normal_state({route, <<"">>,
|
|||||||
case NewStateData of
|
case NewStateData of
|
||||||
stop ->
|
stop ->
|
||||||
Conf = StateData#state.config,
|
Conf = StateData#state.config,
|
||||||
{stop, normal, StateData#state{config = Conf#config{persistent = false}}};
|
{stop, normal, StateData#state{config = Conf#config{persistent = {destroying, Conf#config.persistent}}}};
|
||||||
_ when NewStateData#state.just_created ->
|
_ when NewStateData#state.just_created ->
|
||||||
close_room_if_temporary_and_empty(NewStateData);
|
close_room_if_temporary_and_empty(NewStateData);
|
||||||
_ ->
|
_ ->
|
||||||
@ -736,7 +736,7 @@ handle_event({destroy, Reason}, _StateName,
|
|||||||
[jid:encode(StateData#state.jid), Reason]),
|
[jid:encode(StateData#state.jid), Reason]),
|
||||||
add_to_log(room_existence, destroyed, StateData),
|
add_to_log(room_existence, destroyed, StateData),
|
||||||
Conf = StateData#state.config,
|
Conf = StateData#state.config,
|
||||||
{stop, shutdown, StateData#state{config = Conf#config{persistent = false}}};
|
{stop, shutdown, StateData#state{config = Conf#config{persistent = {destroying, Conf#config.persistent}}}};
|
||||||
handle_event(destroy, StateName, StateData) ->
|
handle_event(destroy, StateName, StateData) ->
|
||||||
?INFO_MSG("Destroyed MUC room ~ts",
|
?INFO_MSG("Destroyed MUC room ~ts",
|
||||||
[jid:encode(StateData#state.jid)]),
|
[jid:encode(StateData#state.jid)]),
|
||||||
@ -856,7 +856,7 @@ handle_sync_event({muc_unsubscribe, From}, _From, StateName,
|
|||||||
from = From, sub_els = [#muc_unsubscribe{}]},
|
from = From, sub_els = [#muc_unsubscribe{}]},
|
||||||
case process_iq_mucsub(From, IQ, StateData) of
|
case process_iq_mucsub(From, IQ, StateData) of
|
||||||
{result, _, stop} ->
|
{result, _, stop} ->
|
||||||
{stop, normal, StateData#state{config = Conf#config{persistent = false}}};
|
{stop, normal, StateData#state{config = Conf#config{persistent = {destroying, Conf#config.persistent}}}};
|
||||||
{result, _, NewState} ->
|
{result, _, NewState} ->
|
||||||
{reply, ok, StateName, NewState};
|
{reply, ok, StateName, NewState};
|
||||||
{ignore, NewState} ->
|
{ignore, NewState} ->
|
||||||
@ -1016,7 +1016,9 @@ terminate(Reason, _StateName,
|
|||||||
add_to_log(room_existence, stopped, StateData),
|
add_to_log(room_existence, stopped, StateData),
|
||||||
case (StateData#state.config)#config.persistent of
|
case (StateData#state.config)#config.persistent of
|
||||||
false ->
|
false ->
|
||||||
ejabberd_hooks:run(room_destroyed, LServer, [LServer, Room, Host]);
|
ejabberd_hooks:run(room_destroyed, LServer, [LServer, Room, Host, false]);
|
||||||
|
{destroying, Persistent} ->
|
||||||
|
ejabberd_hooks:run(room_destroyed, LServer, [LServer, Room, Host, Persistent]);
|
||||||
_ ->
|
_ ->
|
||||||
ok
|
ok
|
||||||
end
|
end
|
||||||
|
Loading…
Reference in New Issue
Block a user