# HG changeset patch # User Kim Alvefur # Date 1479576369 -3600 # Node ID 9332b43931f525f157989a676a933a6b848138bd # Parent ca3bdb606b1fdb7ee2791e474a9697a4a23dd475 mod_mam: Add some comments explaining archive expiry diff -r ca3bdb606b1f -r 9332b43931f5 plugins/mod_mam/mod_mam.lua --- a/plugins/mod_mam/mod_mam.lua Fri Nov 18 10:44:56 2016 +0100 +++ b/plugins/mod_mam/mod_mam.lua Sat Nov 19 18:26:09 2016 +0100 @@ -238,6 +238,7 @@ 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 @@ 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