Diff

plugins/mod_mam/mod_mam.lua @ 7842:9332b43931f5

mod_mam: Add some comments explaining archive expiry
author Kim Alvefur <zash@zash.se>
date Sat, 19 Nov 2016 18:26:09 +0100
parent 7841:ca3bdb606b1f
child 7843:04b09fd144eb
line wrap: on
line diff
--- 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