aboutsummaryrefslogtreecommitdiffstats
path: root/plugins/mod_mam
diff options
context:
space:
mode:
authorKim Alvefur <zash@zash.se>2016-11-19 18:26:09 +0100
committerKim Alvefur <zash@zash.se>2016-11-19 18:26:09 +0100
commite03e8cd897bb2f549a16a041f6deaef4350df909 (patch)
treec2dec2e19fe749fc0f95d342d9ff4ba861967e10 /plugins/mod_mam
parent6f7e52ea70ad518fe033aee8e03bb868974e3f7b (diff)
downloadprosody-e03e8cd897bb2f549a16a041f6deaef4350df909.tar.gz
prosody-e03e8cd897bb2f549a16a041f6deaef4350df909.zip
mod_mam: Add some comments explaining archive expiry
Diffstat (limited to 'plugins/mod_mam')
-rw-r--r--plugins/mod_mam/mod_mam.lua7
1 files changed, 7 insertions, 0 deletions
diff --git a/plugins/mod_mam/mod_mam.lua b/plugins/mod_mam/mod_mam.lua
index 383ed162..d4dae6cc 100644
--- a/plugins/mod_mam/mod_mam.lua
+++ b/plugins/mod_mam/mod_mam.lua
@@ -238,6 +238,7 @@ local function message_handler(event, c2s)
log("debug", "Not archiving stanza: %s (type)", stanza:top_tag());
return;
end
+
-- or if hints suggest we shouldn't
if stanza:get_child("no-permanent-storage", "urn:xmpp:hints") -- The XEP needs to decide on "store" or "storage"
or stanza:get_child("no-permanent-store", "urn:xmpp:hints")
@@ -291,14 +292,20 @@ if cleanup_after ~= "never" then
return false;
end
+ -- Set of known users to do message expiry for
+ -- Populated either below or when new messages are added
cleanup = {};
+ -- Iterating over users is not supported by all authentication modules
+ -- Catch and ignore error if not supported
pcall(function ()
+ -- If this works, then we schedule cleanup for all known known
for user in um.users(module.host) do
cleanup[user] = true;
end
end);
+ -- At odd intervals, delete old messages for one user
module:add_timer(math.random(10, 60), function()
local user = next(cleanup);
if user then