Comparison

plugins/mod_http_file_share.lua @ 13213:50324f66ca2a

plugins: Use integer config API with interval specification where sensible Many of these fall into a few categories: - util.cache size, must be >= 1 - byte or item counts that logically can't be negative - port numbers that should be in 1..0xffff
author Kim Alvefur <zash@zash.se>
date Mon, 17 Jul 2023 01:38:54 +0200
parent 13209:c8d949cf6b09
child 13230:26c30844cac6
comparison
equal deleted inserted replaced
13212:3e6e98cc63e9 13213:50324f66ca2a
34 local persist_stats = module:open_store("upload_stats", "map"); 34 local persist_stats = module:open_store("upload_stats", "map");
35 -- id, <request>, time, owner 35 -- id, <request>, time, owner
36 36
37 local secret = module:get_option_string(module.name.."_secret", require"prosody.util.id".long()); 37 local secret = module:get_option_string(module.name.."_secret", require"prosody.util.id".long());
38 local external_base_url = module:get_option_string(module.name .. "_base_url"); 38 local external_base_url = module:get_option_string(module.name .. "_base_url");
39 local file_size_limit = module:get_option_number(module.name .. "_size_limit", 10 * 1024 * 1024); -- 10 MB 39 local file_size_limit = module:get_option_integer(module.name .. "_size_limit", 10 * 1024 * 1024, 0); -- 10 MB
40 local file_types = module:get_option_set(module.name .. "_allowed_file_types", {}); 40 local file_types = module:get_option_set(module.name .. "_allowed_file_types", {});
41 local safe_types = module:get_option_set(module.name .. "_safe_file_types", {"image/*","video/*","audio/*","text/plain"}); 41 local safe_types = module:get_option_set(module.name .. "_safe_file_types", {"image/*","video/*","audio/*","text/plain"});
42 local expiry = module:get_option_period(module.name .. "_expires_after", "1w"); 42 local expiry = module:get_option_period(module.name .. "_expires_after", "1w");
43 local daily_quota = module:get_option_number(module.name .. "_daily_quota", file_size_limit*10); -- 100 MB / day 43 local daily_quota = module:get_option_integer(module.name .. "_daily_quota", file_size_limit*10, 0); -- 100 MB / day
44 local total_storage_limit = module:get_option_number(module.name.."_global_quota", unlimited); 44 local total_storage_limit = module:get_option_integer(module.name.."_global_quota", unlimited, 0);
45 45
46 local create_jwt, verify_jwt = require"prosody.util.jwt".init("HS256", secret, secret, { default_ttl = 600 }); 46 local create_jwt, verify_jwt = require"prosody.util.jwt".init("HS256", secret, secret, { default_ttl = 600 });
47 47
48 local access = module:get_option_set(module.name .. "_access", {}); 48 local access = module:get_option_set(module.name .. "_access", {});
49 49