aboutsummaryrefslogtreecommitdiffstats
path: root/plugins/mod_http_file_share.lua
diff options
context:
space:
mode:
authorKim Alvefur <zash@zash.se>2023-07-16 20:49:33 +0200
committerKim Alvefur <zash@zash.se>2023-07-16 20:49:33 +0200
commit1987a7411f6aab1b0534ef23dc8797362eae1076 (patch)
tree47c52d7b27c3b76cb1356f1a512105f1df2e8592 /plugins/mod_http_file_share.lua
parent903e945d09ffd94ebf3f08b6c5092a56ad484348 (diff)
downloadprosody-1987a7411f6aab1b0534ef23dc8797362eae1076.tar.gz
prosody-1987a7411f6aab1b0534ef23dc8797362eae1076.zip
plugins: Switch to :get_option_period() for time range options
Improves readability ("1 day" vs 86400) and centralizes validation.
Diffstat (limited to 'plugins/mod_http_file_share.lua')
-rw-r--r--plugins/mod_http_file_share.lua8
1 files changed, 1 insertions, 7 deletions
diff --git a/plugins/mod_http_file_share.lua b/plugins/mod_http_file_share.lua
index f9f227cd..1f9f5b7b 100644
--- a/plugins/mod_http_file_share.lua
+++ b/plugins/mod_http_file_share.lua
@@ -19,7 +19,6 @@ local dt = require "prosody.util.datetime";
local hi = require "prosody.util.human.units";
local cache = require "prosody.util.cache";
local lfs = require "lfs";
-local parse_duration = require "prosody.util.human.io".parse_duration;
local unknown = math.abs(0/0);
local unlimited = math.huge;
@@ -40,12 +39,7 @@ local external_base_url = module:get_option_string(module.name .. "_base_url");
local file_size_limit = module:get_option_number(module.name .. "_size_limit", 10 * 1024 * 1024); -- 10 MB
local file_types = module:get_option_set(module.name .. "_allowed_file_types", {});
local safe_types = module:get_option_set(module.name .. "_safe_file_types", {"image/*","video/*","audio/*","text/plain"});
-local expiry_str = module:get_option_string(module.name .. "_expires_after", "1w");
-local expiry, parse_err = parse_duration(expiry_str);
-if expiry == nil then
- module:log("error", "Could not parse "..module.name.."_expire_after string %q: %s", expiry_str, parse_err);
- return false;
-end
+local expiry = module:get_option_period(module.name .. "_expires_after", "1w");
local daily_quota = module:get_option_number(module.name .. "_daily_quota", file_size_limit*10); -- 100 MB / day
local total_storage_limit = module:get_option_number(module.name.."_global_quota", unlimited);