From bebab75dda323dc31dec03747b8b3e8508f90528 Mon Sep 17 00:00:00 2001 From: Kim Alvefur Date: Sat, 19 Nov 2016 18:26:09 +0100 Subject: mod_mam: Add some comments explaining archive expiry --- plugins/mod_mam/mod_mam.lua | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'plugins') 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 -- cgit v1.2.3