Mercurial > prosody-hg
comparison plugins/mod_muc_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 |
| parents | 74b9e05af71e |
| children | 58083329903d |
comparison
equal
deleted
inserted
replaced
| 13212:3e6e98cc63e9 | 13213:50324f66ca2a |
|---|---|
| 30 local is_stanza = st.is_stanza; | 30 local is_stanza = st.is_stanza; |
| 31 local tostring = tostring; | 31 local tostring = tostring; |
| 32 local time_now = require "prosody.util.time".now; | 32 local time_now = require "prosody.util.time".now; |
| 33 local m_min = math.min; | 33 local m_min = math.min; |
| 34 local timestamp, datestamp = import("prosody.util.datetime", "datetime", "date"); | 34 local timestamp, datestamp = import("prosody.util.datetime", "datetime", "date"); |
| 35 local default_max_items, max_max_items = 20, module:get_option_number("max_archive_query_results", 50); | 35 local default_max_items, max_max_items = 20, module:get_option_integer("max_archive_query_results", 50, 0); |
| 36 | 36 |
| 37 local cleanup_after = module:get_option_string("muc_log_expires_after", "1w"); | 37 local cleanup_after = module:get_option_string("muc_log_expires_after", "1w"); |
| 38 | 38 |
| 39 local default_history_length = 20; | 39 local default_history_length = 20; |
| 40 local max_history_length = module:get_option_number("max_history_messages", math.huge); | 40 local max_history_length = module:get_option_integer("max_history_messages", math.huge, 0); |
| 41 | 41 |
| 42 local function get_historylength(room) | 42 local function get_historylength(room) |
| 43 return math.min(room._data.history_length or default_history_length, max_history_length); | 43 return math.min(room._data.history_length or default_history_length, max_history_length); |
| 44 end | 44 end |
| 45 | 45 |
| 51 local log_by_default = module:get_option_boolean("muc_log_by_default", true); | 51 local log_by_default = module:get_option_boolean("muc_log_by_default", true); |
| 52 | 52 |
| 53 local archive_store = "muc_log"; | 53 local archive_store = "muc_log"; |
| 54 local archive = module:open_store(archive_store, "archive"); | 54 local archive = module:open_store(archive_store, "archive"); |
| 55 | 55 |
| 56 local archive_item_limit = module:get_option_number("storage_archive_item_limit", archive.caps and archive.caps.quota or 1000); | 56 local archive_item_limit = module:get_option_integer("storage_archive_item_limit", archive.caps and archive.caps.quota or 1000, 0); |
| 57 local archive_truncate = math.floor(archive_item_limit * 0.99); | 57 local archive_truncate = math.floor(archive_item_limit * 0.99); |
| 58 | 58 |
| 59 if archive.name == "null" or not archive.find then | 59 if archive.name == "null" or not archive.find then |
| 60 if not archive.find then | 60 if not archive.find then |
| 61 module:log("error", "Attempt to open archive storage returned a driver without archive API support"); | 61 module:log("error", "Attempt to open archive storage returned a driver without archive API support"); |
| 490 | 490 |
| 491 -- For each day, store a set of rooms that have new messages. To expire | 491 -- For each day, store a set of rooms that have new messages. To expire |
| 492 -- messages, we collect the union of sets of rooms from dates that fall | 492 -- messages, we collect the union of sets of rooms from dates that fall |
| 493 -- outside the cleanup range. | 493 -- outside the cleanup range. |
| 494 | 494 |
| 495 local last_date = require "prosody.util.cache".new(module:get_option_number("muc_log_cleanup_date_cache_size", 1000)); | 495 local last_date = require "prosody.util.cache".new(module:get_option_integer("muc_log_cleanup_date_cache_size", 1000, 1)); |
| 496 if not ( archive.caps and archive.caps.wildcard_delete ) then | 496 if not ( archive.caps and archive.caps.wildcard_delete ) then |
| 497 function schedule_cleanup(roomname, date) | 497 function schedule_cleanup(roomname, date) |
| 498 date = date or datestamp(); | 498 date = date or datestamp(); |
| 499 if last_date:get(roomname) == date then return end | 499 if last_date:get(roomname) == date then return end |
| 500 local ok = cleanup_map:set(date, roomname, true); | 500 local ok = cleanup_map:set(date, roomname, true); |
