mirror of
https://github.com/processone/ejabberd.git
synced 2024-12-22 17:28:25 +01:00
Reload internal room's configuration when mod_muc is reloaded
Fixes #2513
This commit is contained in:
parent
a981bf9a59
commit
491993d401
@ -139,7 +139,7 @@ handle_cast(config_reloaded, #state{host_modules = HostModules} = State) ->
|
||||
NewModules = auth_modules(Host),
|
||||
start(Host, NewModules -- OldModules),
|
||||
stop(Host, OldModules -- NewModules),
|
||||
reload(Host, lists_intersection(OldModules, NewModules)),
|
||||
reload(Host, misc:intersection(OldModules, NewModules)),
|
||||
maps:put(Host, NewModules, Acc)
|
||||
end, HostModules, ejabberd_config:get_myhosts()),
|
||||
init_cache(NewHostModules),
|
||||
@ -834,12 +834,6 @@ validate_credentials(User, Server, Password) ->
|
||||
end
|
||||
end.
|
||||
|
||||
lists_intersection(L1, L2) ->
|
||||
lists:filter(
|
||||
fun(E) ->
|
||||
lists:member(E, L2)
|
||||
end, L1).
|
||||
|
||||
import_info() ->
|
||||
[{<<"users">>, 3}].
|
||||
|
||||
|
@ -35,7 +35,7 @@
|
||||
now_to_usec/1, usec_to_now/1, encode_pid/1, decode_pid/2,
|
||||
compile_exprs/2, join_atoms/2, try_read_file/1, get_descr/2,
|
||||
css_dir/0, img_dir/0, js_dir/0, msgs_dir/0, sql_dir/0,
|
||||
read_css/1, read_img/1, read_js/1, try_url/1]).
|
||||
read_css/1, read_img/1, read_js/1, try_url/1, intersection/2]).
|
||||
|
||||
%% Deprecated functions
|
||||
-export([decode_base64/1, encode_base64/1]).
|
||||
@ -280,6 +280,13 @@ get_descr(Lang, Text) ->
|
||||
Copyright = ejabberd_config:get_copyright(),
|
||||
<<Desc/binary, $\n, Copyright/binary>>.
|
||||
|
||||
-spec intersection(list(), list()) -> list().
|
||||
intersection(L1, L2) ->
|
||||
lists:filter(
|
||||
fun(E) ->
|
||||
lists:member(E, L2)
|
||||
end, L1).
|
||||
|
||||
%%%===================================================================
|
||||
%%% Internal functions
|
||||
%%%===================================================================
|
||||
|
@ -295,6 +295,15 @@ handle_cast({reload, ServerHost, NewOpts, OldOpts}, #state{hosts = OldHosts}) ->
|
||||
ejabberd_router:unregister_route(OldHost),
|
||||
unregister_iq_handlers(OldHost)
|
||||
end, OldHosts -- NewHosts),
|
||||
lists:foreach(
|
||||
fun(Host) ->
|
||||
lists:foreach(
|
||||
fun({_, _, Pid}) when node(Pid) == node() ->
|
||||
Pid ! config_reloaded;
|
||||
(_) ->
|
||||
ok
|
||||
end, get_online_rooms(ServerHost, Host))
|
||||
end, misc:intersection(NewHosts, OldHosts)),
|
||||
{noreply, NewState};
|
||||
handle_cast(Msg, State) ->
|
||||
?WARNING_MSG("unexpected cast: ~p", [Msg]),
|
||||
|
@ -678,6 +678,19 @@ handle_info({iq_reply, timeout, IQ}, StateName, StateData) ->
|
||||
Err = xmpp:err_recipient_unavailable(Txt, IQ#iq.lang),
|
||||
ejabberd_router:route_error(IQ, Err),
|
||||
{next_state, StateName, StateData};
|
||||
handle_info(config_reloaded, StateName, StateData) ->
|
||||
Max = gen_mod:get_module_opt(StateData#state.server_host,
|
||||
mod_muc, history_size),
|
||||
History1 = StateData#state.history,
|
||||
Q1 = History1#lqueue.queue,
|
||||
Q2 = case p1_queue:len(Q1) of
|
||||
Len when Len > Max ->
|
||||
lqueue_cut(Q1, Len-Max);
|
||||
_ ->
|
||||
Q1
|
||||
end,
|
||||
History2 = History1#lqueue{queue = Q2, max = Max},
|
||||
{next_state, StateName, StateData#state{history = History2}};
|
||||
handle_info(_Info, StateName, StateData) ->
|
||||
{next_state, StateName, StateData}.
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user