diff options
author | Kim Alvefur <zash@zash.se> | 2023-07-22 12:08:01 +0200 |
---|---|---|
committer | Kim Alvefur <zash@zash.se> | 2023-07-22 12:08:01 +0200 |
commit | 4891b4eea3e83ee08828a3f646f97c1b8c7fe095 (patch) | |
tree | 2c52689a9b126773868a7fab04f2cce88014e2d7 /core | |
parent | e6d0a3e6390ebfb0f39394a10fb12825bcf13b20 (diff) | |
download | prosody-4891b4eea3e83ee08828a3f646f97c1b8c7fe095.tar.gz prosody-4891b4eea3e83ee08828a3f646f97c1b8c7fe095.zip |
core.moduleapi: Parse period min/max arguments
Allows specifying them the same way as the default and in the config,
for consistency
Diffstat (limited to 'core')
-rw-r--r-- | core/moduleapi.lua | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/core/moduleapi.lua b/core/moduleapi.lua index fdd2ef30..8710b243 100644 --- a/core/moduleapi.lua +++ b/core/moduleapi.lua @@ -295,10 +295,16 @@ function api:get_option_period(name, default_value, min, max) return math.huge; end + if type(min) == "string" then + min = human_io.parse_duration(min); + end if min and ret < min then self:log("warn", "Config option '%s' out of bounds %g < %g", name, ret, min); return min; end + if type(max) == "string" then + max = human_io.parse_duration(max); + end if max and ret > max then self:log("warn", "Config option '%s' out of bounds %g > %g", name, ret, max); return max; |