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_sm.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 'src/ejabberd_sm.erl')
-rw-r--r-- | src/ejabberd_sm.erl | 13 |
1 files changed, 2 insertions, 11 deletions
diff --git a/src/ejabberd_sm.erl b/src/ejabberd_sm.erl index 20614a58..ce2abfff 100644 --- a/src/ejabberd_sm.erl +++ b/src/ejabberd_sm.erl @@ -865,14 +865,9 @@ force_update_presence({LUser, LServer}) -> -spec get_sm_backend(binary()) -> module(). get_sm_backend(Host) -> - DBType = case ejabberd_config:get_option( + DBType = ejabberd_config:get_option( {sm_db_type, Host}, - fun(T) -> ejabberd_config:v_db(?MODULE, T) end) of - undefined -> - ejabberd_config:default_ram_db(Host, ?MODULE); - T -> - T - end, + ejabberd_config:default_ram_db(Host, ?MODULE)), list_to_atom("ejabberd_sm_" ++ atom_to_list(DBType)). -spec get_sm_backends() -> [module()]. @@ -904,15 +899,12 @@ init_cache() -> cache_opts() -> MaxSize = ejabberd_config:get_option( sm_cache_size, - opt_type(sm_cache_size), ejabberd_config:cache_size(global)), CacheMissed = ejabberd_config:get_option( sm_cache_missed, - opt_type(sm_cache_missed), ejabberd_config:cache_missed(global)), LifeTime = case ejabberd_config:get_option( sm_cache_life_time, - opt_type(sm_cache_life_time), ejabberd_config:cache_life_time(global)) of infinity -> infinity; I -> timer:seconds(I) @@ -943,7 +935,6 @@ use_cache(Mod, LServer) -> false -> ejabberd_config:get_option( {sm_use_cache, LServer}, - ejabberd_sm:opt_type(sm_use_cache), ejabberd_config:use_cache(LServer)) end. |