aboutsummaryrefslogtreecommitdiffstats
path: root/plugins/mod_mam/mod_mam.lua
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
commitbebab75dda323dc31dec03747b8b3e8508f90528 (patch)
treec2dec2e19fe749fc0f95d342d9ff4ba861967e10 /plugins/mod_mam/mod_mam.lua
parentb39bde756e092de1e32cf97ea5f4cb04f3dbf46d (diff)
downloadprosody-bebab75dda323dc31dec03747b8b3e8508f90528.tar.gz
prosody-bebab75dda323dc31dec03747b8b3e8508f90528.zip
mod_mam: Add some comments explaining archive expiry
Diffstat (limited to 'plugins/mod_mam/mod_mam.lua')
-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