# HG changeset patch # User Kim Alvefur # Date 1487545785 -3600 # Node ID 66a61f48e376c7b1c4963841ee4beeb0aad3ed35 # Parent bc7539ccbde18b7ae177a92374cc3ee0ac77560e mod_mam: Add comments diff -r bc7539ccbde1 -r 66a61f48e376 mod_mam/mod_mam.lua --- a/mod_mam/mod_mam.lua Mon Feb 20 00:48:31 2017 +0100 +++ b/mod_mam/mod_mam.lua Mon Feb 20 00:09:45 2017 +0100 @@ -320,14 +320,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 users on startup 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