Skip to content

Commit

Permalink
Changing opts in mod_time to map
Browse files Browse the repository at this point in the history
  • Loading branch information
Janusz Jakubiec authored and Janusz Jakubiec committed Feb 18, 2022
1 parent c431f16 commit 6365143
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 5 deletions.
2 changes: 1 addition & 1 deletion big_tests/tests/mod_time_SUITE.erl
Original file line number Diff line number Diff line change
Expand Up @@ -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, #{iqdisc => one_queue}),
escalus:init_per_suite(Config).

end_per_suite(Config) ->
Expand Down
11 changes: 7 additions & 4 deletions src/mod_time.erl
Original file line number Diff line number Diff line change
Expand Up @@ -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 | {erorr, 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).

Expand All @@ -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()]}};
Expand Down
2 changes: 2 additions & 0 deletions test/common/config_parser_helper.erl
Original file line number Diff line number Diff line change
Expand Up @@ -833,5 +833,7 @@ default_mod_config(mod_inbox) ->
remove_on_kicked => true,
reset_markers => [<<"displayed">>],
iqdisc => no_queue};
default_mod_config(mod_time) ->
#{iqdisc => one_queue};
default_mod_config(mod_version) ->
#{iqdisc => no_queue, os_info => false}.
1 change: 1 addition & 0 deletions test/config_parser_SUITE.erl
Original file line number Diff line number Diff line change
Expand Up @@ -2920,6 +2920,7 @@ mod_stream_management_stale_h(_Config) ->

mod_time(_Config) ->
check_iqdisc(mod_time),
check_module_defaults(mod_time),
?cfgh(modopts(mod_time, []), #{<<"modules">> => #{<<"mod_time">> => #{}}}).

mod_vcard(_Config) ->
Expand Down

0 comments on commit 6365143

Please sign in to comment.