diff --git a/src/gen_mod.erl b/src/gen_mod.erl index 4dc972fd9..6804d4785 100644 --- a/src/gen_mod.erl +++ b/src/gen_mod.erl @@ -44,7 +44,7 @@ %% Deprecated functions -export([get_opt/3, get_opt/4, get_module_opt/4, get_module_opt/5, get_opt_host/3, get_opt_hosts/3, db_type/2, db_type/3, - ram_db_type/2, ram_db_type/3]). + ram_db_type/2, ram_db_type/3, update_module_opts/3]). -deprecated([{get_opt, 3}, {get_opt, 4}, {get_opt_host, 3}, @@ -305,6 +305,19 @@ store_options(Host, Module, Opts, Order) -> #ejabberd_module{module_host = {Module, Host}, opts = Opts, order = Order}). +-spec update_module_opts(binary(), module(), opts()) -> ok | {ok, pid()} | error. +update_module_opts(Host, Module, NewValues) -> + case ets:lookup(ejabberd_modules, {Module, Host}) of + #ejabberd_module{opts = Opts, order = Order} -> + NewOpts = lists:foldl( + fun({K, _} = KV, Acc) -> + lists:keystore(K, 1, Acc, KV) + end, Opts, NewValues), + reload_module(Host, Module, NewOpts, Opts, Order); + _ -> + error + end. + maybe_halt_ejabberd() -> case is_app_running(ejabberd) of false -> diff --git a/test/offline_tests.erl b/test/offline_tests.erl index fbf1fbf74..d86cc36b9 100644 --- a/test/offline_tests.erl +++ b/test/offline_tests.erl @@ -144,7 +144,8 @@ unsupported_iq(Config) -> master_slave_cases() -> {offline_master_slave, [sequence], [master_slave_test(flex), - master_slave_test(send_all)]}. + master_slave_test(send_all), + master_slave_test(from_mam)]}. flex_master(Config) -> send_messages(Config, 5), @@ -174,6 +175,17 @@ flex_slave(Config) -> 0 = get_number(Config), clean(disconnect(Config)). +offline_from_mam_master(Config) -> + Server = ?config(server, Config), + gen_mod:update_module_opts(Server, mod_offline, [{use_mam_for_storage, true}]), + send_all_master(Config), + gen_mod:update_module_opts(Server, mod_offline, [{use_mam_for_storage, false}]), + wait_for_slave(Config). + +offline_from_mam_slave(Config) -> + send_all_slave(Config), + wait_for_master(Config). + send_all_master(Config) -> wait_for_slave(Config), Peer = ?config(peer, Config), @@ -298,7 +310,7 @@ get_nodes(Config) -> MyBareJID = jid:remove_resource(MyJID), Peer = ?config(peer, Config), Peer_s = jid:encode(Peer), - ct:comment("Getting headers"), + ct:comment("Getting headers"), #iq{type = result, sub_els = [#disco_items{ node = ?NS_FLEX_OFFLINE,