Changeset

9758:d4a534e6bd7c

mod_mam: Handle expiry of messages that expire in the middle of the cut-off day
author Kim Alvefur <zash@zash.se>
date Sun, 06 Jan 2019 09:44:55 +0100
parents 9757:03ed7f10d8da
children 9759:1af5106a2c34
files plugins/mod_mam/mod_mam.lua
diffstat 1 files changed, 6 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/plugins/mod_mam/mod_mam.lua	Sun Jan 06 09:34:59 2019 +0100
+++ b/plugins/mod_mam/mod_mam.lua	Sun Jan 06 09:44:55 2019 +0100
@@ -358,14 +358,18 @@
 		local users = {};
 		local cut_off = datestamp(os.time() - cleanup_after);
 		for date in cleanup_storage:users() do
-			if date < cut_off then
+			if date <= cut_off then
 				module:log("debug", "Messages from %q should be expired", date);
 				local messages_this_day = cleanup_storage:get(date);
 				if messages_this_day then
 					for user in pairs(messages_this_day) do
 						users[user] = true;
 					end
-					cleanup_storage:set(date, nil);
+					if date < cut_off then
+						-- Messages from the same day as the cut-off might not have expired yet,
+						-- but all earlier will have, so clear storage for those days.
+						cleanup_storage:set(date, nil);
+					end
 				end
 			end
 		end