aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorEvgeniy Khramtsov <ekhramtsov@process-one.net>2017-04-20 18:55:16 +0300
committerEvgeniy Khramtsov <ekhramtsov@process-one.net>2017-04-20 18:55:16 +0300
commit5444475b1dddd1018bb263b6931c4a0741a66732 (patch)
treea635ad5f0867dd36ec975d75b7747bf8c958aa5e /src
parentUse new cache API in mod_mam (diff)
Correct option validation
Diffstat (limited to 'src')
-rw-r--r--src/mod_caps.erl4
-rw-r--r--src/mod_mam.erl14
2 files changed, 11 insertions, 7 deletions
diff --git a/src/mod_caps.erl b/src/mod_caps.erl
index ee28fd5f3..56eaf5f4f 100644
--- a/src/mod_caps.erl
+++ b/src/mod_caps.erl
@@ -537,7 +537,9 @@ import_next(LServer, DBType, NodePair) ->
import_next(LServer, DBType, ets:next(caps_features_tmp, NodePair)).
mod_opt_type(O) when O == cache_life_time; O == cache_size ->
- fun (I) when is_integer(I), I > 0 -> I end;
+ fun (I) when is_integer(I), I > 0 -> I;
+ (infinity) -> infinity
+ end;
mod_opt_type(O) when O == use_cache; O == cache_missed ->
fun (B) when is_boolean(B) -> B end;
mod_opt_type(db_type) -> fun(T) -> ejabberd_config:v_db(?MODULE, T) end;
diff --git a/src/mod_mam.erl b/src/mod_mam.erl
index 134886988..5a61df327 100644
--- a/src/mod_mam.erl
+++ b/src/mod_mam.erl
@@ -1041,10 +1041,12 @@ get_commands_spec() ->
mod_opt_type(assume_mam_usage) ->
fun (B) when is_boolean(B) -> B end;
-mod_opt_type(cache_life_time) ->
- fun (I) when is_integer(I), I > 0 -> I end;
-mod_opt_type(cache_size) ->
- fun (I) when is_integer(I), I > 0 -> I end;
+mod_opt_type(O) when O == cache_life_time; O == cache_size ->
+ fun (I) when is_integer(I), I > 0 -> I;
+ (infinity) -> infinity
+ end;
+mod_opt_type(O) when O == use_cache; O == cache_missed ->
+ fun (B) when is_boolean(B) -> B end;
mod_opt_type(db_type) -> fun(T) -> ejabberd_config:v_db(?MODULE, T) end;
mod_opt_type(default) ->
fun (always) -> always;
@@ -1055,5 +1057,5 @@ mod_opt_type(iqdisc) -> fun gen_iq_handler:check_type/1;
mod_opt_type(request_activates_archiving) ->
fun (B) when is_boolean(B) -> B end;
mod_opt_type(_) ->
- [assume_mam_usage, cache_life_time, cache_size, db_type, default, iqdisc,
- request_activates_archiving].
+ [assume_mam_usage, cache_life_time, cache_size, use_cache, cache_missed,
+ db_type, default, iqdisc, request_activates_archiving].