diff options
author | Evgeniy Khramtsov <ekhramtsov@process-one.net> | 2017-04-29 11:39:40 +0300 |
---|---|---|
committer | Evgeniy Khramtsov <ekhramtsov@process-one.net> | 2017-04-29 11:39:40 +0300 |
commit | b82b93f8f0c229e94a89469b0754bab0e28cd17c (patch) | |
tree | 56f5c7a25aa19254b4f30b1cf33fc34dcbadcbb7 /src/ejabberd_oauth.erl | |
parent | Don't re-define validation functions in multiple places (diff) |
Don't validate an option in ejabberd_config:get_option() functions
The commit introduces the following changes:
* Now there is no need to pass validating function in
ejabberd_config:get_option() functions, because the configuration
keeps already validated values.
* New function ejabberd_config:get_option/1 is introduced
* Function ejabberd_config:get_option/3 is deprecated. If the function
is still called, the second argument (validating function) is simply
ignored.
* The second argument for ejabberd_config:get_option/2 is now
a default value, not a validating function.
Diffstat (limited to '')
-rw-r--r-- | src/ejabberd_oauth.erl | 17 |
1 files changed, 5 insertions, 12 deletions
diff --git a/src/ejabberd_oauth.erl b/src/ejabberd_oauth.erl index 8527c927..455db85a 100644 --- a/src/ejabberd_oauth.erl +++ b/src/ejabberd_oauth.erl @@ -27,6 +27,7 @@ -module(ejabberd_oauth). -behaviour(gen_server). +-behaviour(ejabberd_config). -compile(export_all). @@ -199,7 +200,6 @@ authenticate_user({User, Server}, Ctx) -> Access = ejabberd_config:get_option( {oauth_access, JID#jid.lserver}, - fun(A) -> A end, none), case acl:match_rule(JID#jid.lserver, Access, JID) of allow -> @@ -402,22 +402,19 @@ use_cache(DBMod) -> true -> DBMod:use_cache(); false -> ejabberd_config:get_option( - oauth_use_cache, opt_type(oauth_use_cache), + oauth_use_cache, ejabberd_config:use_cache(global)) end. cache_opts() -> MaxSize = ejabberd_config:get_option( oauth_cache_size, - opt_type(oauth_cache_size), ejabberd_config:cache_size(global)), CacheMissed = ejabberd_config:get_option( oauth_cache_missed, - opt_type(oauth_cache_missed), ejabberd_config:cache_missed(global)), LifeTime = case ejabberd_config:get_option( oauth_cache_life_time, - opt_type(oauth_cache_life_time), ejabberd_config:cache_life_time(global)) of infinity -> infinity; I -> timer:seconds(I) @@ -425,10 +422,7 @@ cache_opts() -> [{max_size, MaxSize}, {life_time, LifeTime}, {cache_missed, CacheMissed}]. expire() -> - ejabberd_config:get_option( - oauth_expire, - fun(I) when is_integer(I) -> I end, - ?EXPIRE). + ejabberd_config:get_option(oauth_expire, ?EXPIRE). -define(DIV(Class, Els), ?XAE(<<"div">>, [{<<"class">>, Class}], Els)). @@ -623,9 +617,8 @@ process(_Handlers, _Request) -> get_db_backend() -> DBType = ejabberd_config:get_option( - oauth_db_type, - fun(T) -> ejabberd_config:v_db(?MODULE, T) end, - mnesia), + oauth_db_type, + ejabberd_config:default_db(?MODULE)), list_to_atom("ejabberd_oauth_" ++ atom_to_list(DBType)). |