diff --git a/big_tests/tests/mod_time_SUITE.erl b/big_tests/tests/mod_time_SUITE.erl index 71e55218af..90ec4e81d3 100644 --- a/big_tests/tests/mod_time_SUITE.erl +++ b/big_tests/tests/mod_time_SUITE.erl @@ -39,7 +39,7 @@ suite() -> %%-------------------------------------------------------------------- init_per_suite(Config) -> - dynamic_modules:start(domain_helper:host_type(), mod_time, []), + dynamic_modules:start(domain_helper:host_type(), mod_time, config_parser_helper:default_mod_config(mod_time)), escalus:init_per_suite(Config). end_per_suite(Config) -> diff --git a/src/mod_time.erl b/src/mod_time.erl index acc0a98919..57374fcfb3 100644 --- a/src/mod_time.erl +++ b/src/mod_time.erl @@ -24,12 +24,12 @@ -xep([{xep, 202}, {version, "2.0"}]). -xep([{xep, 82}, {version, "1.1"}]). -start(HostType, Opts) -> - IQDisc = gen_mod:get_opt(iqdisc, Opts, one_queue), +-spec start(HostType :: mongooseim:host_type(), gen_mod:module_opts()) -> ok | {error, atom()}. +start(HostType, #{iqdisc := IQDisc}) -> gen_iq_handler:add_iq_handler_for_domain(HostType, ?NS_TIME, ejabberd_local, fun ?MODULE:process_local_iq/5, #{}, IQDisc). - +-spec stop(HostType :: mongooseim:host_type()) -> ok | {error, not_registered}. stop(HostType) -> gen_iq_handler:remove_iq_handler_for_domain(HostType, ?NS_TIME, ejabberd_local). @@ -40,7 +40,10 @@ supported_features() -> -spec config_spec() -> mongoose_config_spec:config_section(). config_spec() -> #section{ - items = #{<<"iqdisc">> => mongoose_config_spec:iqdisc()}}. + items = #{<<"iqdisc">> => mongoose_config_spec:iqdisc()}, + defaults = #{<<"iqdisc">> => one_queue}, + format_items = map + }. process_local_iq(Acc, _From, _To, #iq{type = set, sub_el = SubEl} = IQ, _Extra) -> {Acc, IQ#iq{type = error, sub_el = [SubEl, mongoose_xmpp_errors:not_allowed()]}}; diff --git a/test/common/config_parser_helper.erl b/test/common/config_parser_helper.erl index 2e2f573c45..71e0abaf8a 100644 --- a/test/common/config_parser_helper.erl +++ b/test/common/config_parser_helper.erl @@ -836,6 +836,8 @@ default_mod_config(mod_inbox) -> iqdisc => no_queue}; default_mod_config(mod_private) -> #{iqdisc => one_queue, backend => rdbms}; +default_mod_config(mod_time) -> + #{iqdisc => one_queue}; default_mod_config(mod_vcard) -> #{iqdisc => parallel, host => {prefix, <<"vjud.">>}, diff --git a/test/config_parser_SUITE.erl b/test/config_parser_SUITE.erl index 110e6cafbd..7e7ef83977 100644 --- a/test/config_parser_SUITE.erl +++ b/test/config_parser_SUITE.erl @@ -2920,8 +2920,8 @@ mod_stream_management_stale_h(_Config) -> ?errh(T(#{<<"geriatric">> => <<"one">>})). mod_time(_Config) -> - check_iqdisc(mod_time), - ?cfgh(modopts(mod_time, []), #{<<"modules">> => #{<<"mod_time">> => #{}}}). + check_iqdisc_map(mod_time), + check_module_defaults(mod_time). mod_vcard(_Config) -> check_module_defaults(mod_vcard),