Mercurial > prosody-modules
comparison mod_mam/mod_mam.lua @ 2022:77b9c7e5fd63
mod_mam: Allow interval between archive cleanup to be changed
author | Kim Alvefur <zash@zash.se> |
---|---|
date | Tue, 19 Jan 2016 17:47:05 +0100 |
parents | 5fb917b86838 |
children | 98b4794b72e4 |
comparison
equal
deleted
inserted
replaced
2021:5fb917b86838 | 2022:77b9c7e5fd63 |
---|---|
270 local function c2s_message_handler(event) | 270 local function c2s_message_handler(event) |
271 return message_handler(event, true); | 271 return message_handler(event, true); |
272 end | 272 end |
273 | 273 |
274 local cleanup_after = module:get_option_string("archive_expires_after", "1w"); | 274 local cleanup_after = module:get_option_string("archive_expires_after", "1w"); |
275 local cleanup_interval = module:get_option_number("archive_expire_interval", 4 * 60 * 60); | 275 local cleanup_interval = module:get_option_number("archive_cleanup_interval", 4 * 60 * 60); |
276 if cleanup_after ~= "never" then | 276 if cleanup_after ~= "never" then |
277 local day = 86400; | 277 local day = 86400; |
278 local multipliers = { d = day, w = day * 7, m = 31 * day, y = 365.2425 * day }; | 278 local multipliers = { d = day, w = day * 7, m = 31 * day, y = 365.2425 * day }; |
279 local n, m = cleanup_after:lower():match("(%d+)%s*([dmy]?)"); | 279 local n, m = cleanup_after:lower():match("(%d+)%s*([dmy]?)"); |
280 if not n then | 280 if not n then |
306 if not ok then | 306 if not ok then |
307 module:log("warn", "Could not expire archives for user %s: %s", user, err); | 307 module:log("warn", "Could not expire archives for user %s: %s", user, err); |
308 end | 308 end |
309 user[cleanup] = nil; | 309 user[cleanup] = nil; |
310 end | 310 end |
311 return 14400; | 311 return cleanup_interval; |
312 end); | 312 end); |
313 end | 313 end |
314 | 314 |
315 -- Stanzas sent by local clients | 315 -- Stanzas sent by local clients |
316 module:hook("pre-message/bare", c2s_message_handler, 2); | 316 module:hook("pre-message/bare", c2s_message_handler, 2); |