Software /
code /
prosody
Comparison
plugins/mod_mam/mod_mam.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 |
---|---|
35 local is_stanza = st.is_stanza; | 35 local is_stanza = st.is_stanza; |
36 local tostring = tostring; | 36 local tostring = tostring; |
37 local time_now = require "prosody.util.time".now; | 37 local time_now = require "prosody.util.time".now; |
38 local m_min = math.min; | 38 local m_min = math.min; |
39 local timestamp, datestamp = import( "util.datetime", "datetime", "date"); | 39 local timestamp, datestamp = import( "util.datetime", "datetime", "date"); |
40 local default_max_items, max_max_items = 20, module:get_option_number("max_archive_query_results", 50); | 40 local default_max_items, max_max_items = 20, module:get_option_integer("max_archive_query_results", 50, 0); |
41 local strip_tags = module:get_option_set("dont_archive_namespaces", { "http://jabber.org/protocol/chatstates" }); | 41 local strip_tags = module:get_option_set("dont_archive_namespaces", { "http://jabber.org/protocol/chatstates" }); |
42 | 42 |
43 local archive_store = module:get_option_string("archive_store", "archive"); | 43 local archive_store = module:get_option_string("archive_store", "archive"); |
44 local archive = module:open_store(archive_store, "archive"); | 44 local archive = module:open_store(archive_store, "archive"); |
45 | 45 |
46 local cleanup_after = module:get_option_period("archive_expires_after", "1w"); | 46 local cleanup_after = module:get_option_period("archive_expires_after", "1w"); |
47 local archive_item_limit = module:get_option_number("storage_archive_item_limit", archive.caps and archive.caps.quota or 1000); | 47 local archive_item_limit = module:get_option_integer("storage_archive_item_limit", archive.caps and archive.caps.quota or 1000, 0); |
48 local archive_truncate = math.floor(archive_item_limit * 0.99); | 48 local archive_truncate = math.floor(archive_item_limit * 0.99); |
49 | 49 |
50 if not archive.find then | 50 if not archive.find then |
51 error("mod_"..(archive._provided_by or archive.name and "storage_"..archive.name).." does not support archiving\n" | 51 error("mod_"..(archive._provided_by or archive.name and "storage_"..archive.name).." does not support archiving\n" |
52 .."See https://prosody.im/doc/storage and https://prosody.im/doc/archiving for more information"); | 52 .."See https://prosody.im/doc/storage and https://prosody.im/doc/archiving for more information"); |
520 -- For each day, store a set of users that have new messages. To expire | 520 -- For each day, store a set of users that have new messages. To expire |
521 -- messages, we collect the union of sets of users from dates that fall | 521 -- messages, we collect the union of sets of users from dates that fall |
522 -- outside the cleanup range. | 522 -- outside the cleanup range. |
523 | 523 |
524 if not (archive.caps and archive.caps.wildcard_delete) then | 524 if not (archive.caps and archive.caps.wildcard_delete) then |
525 local last_date = require "prosody.util.cache".new(module:get_option_number("archive_cleanup_date_cache_size", 1000)); | 525 local last_date = require "prosody.util.cache".new(module:get_option_integer("archive_cleanup_date_cache_size", 1000, 1)); |
526 function schedule_cleanup(username, date) | 526 function schedule_cleanup(username, date) |
527 date = date or datestamp(); | 527 date = date or datestamp(); |
528 if last_date:get(username) == date then return end | 528 if last_date:get(username) == date then return end |
529 local ok = cleanup_map:set(date, username, true); | 529 local ok = cleanup_map:set(date, username, true); |
530 if ok then | 530 if ok then |