aboutsummaryrefslogtreecommitdiffstats
path: root/core
diff options
context:
space:
mode:
authorKim Alvefur <zash@zash.se>2023-07-16 21:01:31 +0200
committerKim Alvefur <zash@zash.se>2023-07-16 21:01:31 +0200
commitf3aac1a4be9ba4219942a8314868c4634e1b090c (patch)
tree45afefb40856d65d634815ea587dd0243440cf06 /core
parent15a2cec870fad566a4519dbc12e05c0ddace2140 (diff)
downloadprosody-f3aac1a4be9ba4219942a8314868c4634e1b090c.tar.gz
prosody-f3aac1a4be9ba4219942a8314868c4634e1b090c.zip
core.moduleapi: Turn negative periods or "never" into infinity
As a way to signal that the periodic thing should be disabled, matching existing mod_mam usage
Diffstat (limited to 'core')
-rw-r--r--core/moduleapi.lua7
1 files changed, 7 insertions, 0 deletions
diff --git a/core/moduleapi.lua b/core/moduleapi.lua
index 88dd5b41..8fa1b672 100644
--- a/core/moduleapi.lua
+++ b/core/moduleapi.lua
@@ -257,8 +257,15 @@ end
function api:get_option_period(name, default_value)
local value = self:get_option_scalar(name, default_value);
if type(value) == "number" then
+ if value < 0 then
+ self:log("debug", "Treating negative period as infinity");
+ return math.huge;
+ end
-- assume seconds
return value;
+ elseif value == "never" then
+ -- usually for disabling some periodic thing
+ return math.huge;
elseif type(value) == "string" then
local ret = human_io.parse_duration(value);
if value ~= nil and ret == nil then