From: Paweł Chmielowski Date: Tue, 15 Oct 2019 09:18:29 +0000 (+0200) Subject: Convert oauth_expire option to accept timeout values X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=9822535e70f15651f19c20e7183dfec7de2870e3;p=ejabberd Convert oauth_expire option to accept timeout values --- diff --git a/src/ejabberd_oauth.erl b/src/ejabberd_oauth.erl index 3c95dbb36..1ba1505b7 100644 --- a/src/ejabberd_oauth.erl +++ b/src/ejabberd_oauth.erl @@ -202,11 +202,11 @@ init([]) -> init_cache(DBMod), Expire = expire(), application:set_env(oauth2, backend, ejabberd_oauth), - application:set_env(oauth2, expiry_time, Expire), + application:set_env(oauth2, expiry_time, Expire div 1000), application:start(oauth2), ejabberd_commands:register_commands(get_commands_spec()), ejabberd_hooks:add(config_reloaded, ?MODULE, config_reloaded, 50), - erlang:send_after(expire() * 1000, self(), clean), + erlang:send_after(expire(), self(), clean), {ok, ok}. handle_call(Request, From, State) -> @@ -222,7 +222,7 @@ handle_info(clean, State) -> TS = 1000000 * MegaSecs + Secs, DBMod = get_db_backend(), DBMod:clean(TS), - erlang:send_after(trunc(expire() * 1000 * (1 + MiniSecs / 1000000)), + erlang:send_after(trunc(expire() * (1 + MiniSecs / 1000000)), self(), clean), {noreply, State}; handle_info(Info, State) -> diff --git a/src/ejabberd_option.erl b/src/ejabberd_option.erl index 94e79d80d..81b0f0c11 100644 --- a/src/ejabberd_option.erl +++ b/src/ejabberd_option.erl @@ -632,7 +632,7 @@ oauth_client_id_check(Host) -> oauth_db_type() -> ejabberd_config:get_option({oauth_db_type, global}). --spec oauth_expire() -> non_neg_integer(). +-spec oauth_expire() -> pos_integer(). oauth_expire() -> ejabberd_config:get_option({oauth_expire, global}). diff --git a/src/ejabberd_options.erl b/src/ejabberd_options.erl index 7bfa06ee6..126891bc2 100644 --- a/src/ejabberd_options.erl +++ b/src/ejabberd_options.erl @@ -231,7 +231,7 @@ opt_type(oauth_cache_size) -> opt_type(oauth_db_type) -> econf:db_type(ejabberd_oauth); opt_type(oauth_expire) -> - econf:non_neg_int(); + econf:timeout(second); opt_type(oauth_use_cache) -> econf:bool(); opt_type(oauth_client_id_check) ->