diff options
author | Evgeniy Khramtsov <ekhramtsov@process-one.net> | 2017-04-30 19:01:47 +0300 |
---|---|---|
committer | Evgeniy Khramtsov <ekhramtsov@process-one.net> | 2017-04-30 19:01:47 +0300 |
commit | fddd6110e00df12c99a20a2cc9d074f5f4f1f965 (patch) | |
tree | 366575b855f1b2013db7eeb02ecb213f81c98c1f /src/mod_delegation.erl | |
parent | Merge branch 'new-option-validation' (diff) |
Don't validate an option in gen_mod:get*opt() functions
The changes are very similar to those from previous commit:
* Now there is no need to pass validating function in
gen_mod:get_opt() and gen_mod:get_module_opt() functions,
because the modules' configuration keeps already validated values.
* New functions gen_mod:get_opt/2 and gen_mod:get_module_opt/3 are
introduced.
* Functions gen_mod:get_opt/4 and get_module_opt/5 are deprecated.
If the functions are still called, the "function" argument is
simply ignored.
* Validating callback Mod:listen_opt_type/1 is introduced to validate
listening options at startup.
Diffstat (limited to 'src/mod_delegation.erl')
-rw-r--r-- | src/mod_delegation.erl | 23 |
1 files changed, 10 insertions, 13 deletions
diff --git a/src/mod_delegation.erl b/src/mod_delegation.erl index baad79af..f41c7610 100644 --- a/src/mod_delegation.erl +++ b/src/mod_delegation.erl @@ -61,7 +61,15 @@ reload(_Host, _NewOpts, _OldOpts) -> ok. mod_opt_type(iqdisc) -> fun gen_iq_handler:check_type/1; -mod_opt_type(namespaces) -> validate_fun(); +mod_opt_type(namespaces) -> + fun(L) -> + lists:map( + fun({NS, Opts}) -> + Attrs = proplists:get_value(filtering, Opts, []), + Access = proplists:get_value(access, Opts, none), + {NS, Attrs, Access} + end, L) + end; mod_opt_type(_) -> [namespaces, iqdisc]. @@ -142,8 +150,7 @@ handle_cast({component_connected, Host}, State) -> ServerHost = State#state.server_host, To = jid:make(Host), NSAttrsAccessList = gen_mod:get_module_opt( - ServerHost, ?MODULE, namespaces, - validate_fun(), []), + ServerHost, ?MODULE, namespaces, []), lists:foreach( fun({NS, _Attrs, Access}) -> case acl:match_rule(ServerHost, Access, To) of @@ -342,13 +349,3 @@ disco_identity(Acc, _From, _To, _Node, _Lang, _Type) -> my_features(ejabberd_local) -> [?NS_DELEGATION]; my_features(ejabberd_sm) -> []. - -validate_fun() -> - fun(L) -> - lists:map( - fun({NS, Opts}) -> - Attrs = proplists:get_value(filtering, Opts, []), - Access = proplists:get_value(access, Opts, none), - {NS, Attrs, Access} - end, L) - end. |