mod_smacks: Record timestamp with persisted counters
authorKim Alvefur <zash@zash.se>
Fri, 31 Dec 2021 00:18:13 +0100
changeset 12139 fa804c2db747
parent 12138 912614c4bf3e
child 12140 6366240d2edb
mod_smacks: Record timestamp with persisted counters For future cleanup routine when people inevitably complain about this data being stored there forever
plugins/mod_smacks.lua
--- a/plugins/mod_smacks.lua	Wed Dec 29 18:03:26 2021 +0100
+++ b/plugins/mod_smacks.lua	Fri Dec 31 00:18:13 2021 +0100
@@ -467,7 +467,8 @@
 
 		session.log("debug", "Destroying session for hibernating too long");
 		session_registry[jid.join(session.username, session.host, session.resumption_token)] = nil;
-		old_session_registry:set(session.username, session.resumption_token, { h = session.handled_stanza_count });
+		old_session_registry:set(session.username, session.resumption_token,
+			{ h = session.handled_stanza_count; t = os.time() });
 		session.resumption_token = nil;
 		session.resending_unacked = true; -- stop outgoing_stanza_filter from re-queueing anything anymore
 		sessionmanager.destroy_session(session, "Hibernating too long");
@@ -681,7 +682,8 @@
 	for _, user in pairs(local_sessions) do
 		for _, session in pairs(user.sessions) do
 			if session.resumption_token then
-				if old_session_registry:set(session.username, session.resumption_token, { h = session.handled_stanza_count }) then
+				if old_session_registry:set(session.username, session.resumption_token,
+					{ h = session.handled_stanza_count; t = os.time() }) then
 					session.resumption_token = nil;
 
 					-- Deal with unacked stanzas