aboutsummaryrefslogtreecommitdiffstats
path: root/plugins
diff options
context:
space:
mode:
authorKim Alvefur <zash@zash.se>2019-01-06 09:44:55 +0100
committerKim Alvefur <zash@zash.se>2019-01-06 09:44:55 +0100
commitbdfc36fc8caa83c2919c0df1f46b91232af09096 (patch)
tree3db97a815c50038b9b3a54a06bdc5d4e34859c3c /plugins
parent2ac699495592895c1cde86cb0ba2dc25c254a4eb (diff)
downloadprosody-bdfc36fc8caa83c2919c0df1f46b91232af09096.tar.gz
prosody-bdfc36fc8caa83c2919c0df1f46b91232af09096.zip
mod_mam: Handle expiry of messages that expire in the middle of the cut-off day
Diffstat (limited to 'plugins')
-rw-r--r--plugins/mod_mam/mod_mam.lua8
1 files changed, 6 insertions, 2 deletions
diff --git a/plugins/mod_mam/mod_mam.lua b/plugins/mod_mam/mod_mam.lua
index 5ba04d68..d2ca709b 100644
--- a/plugins/mod_mam/mod_mam.lua
+++ b/plugins/mod_mam/mod_mam.lua
@@ -358,14 +358,18 @@ if cleanup_after ~= "never" then
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