# HG changeset patch # User Kim Alvefur # Date 1546764295 -3600 # Node ID d4a534e6bd7ce2c4e40815da0e66510b768fb52b # Parent 03ed7f10d8da868ac70c91c939af835dec7c598c mod_mam: Handle expiry of messages that expire in the middle of the cut-off day diff -r 03ed7f10d8da -r d4a534e6bd7c plugins/mod_mam/mod_mam.lua --- 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