diff options
author | Kim Alvefur <zash@zash.se> | 2020-05-05 22:21:39 +0200 |
---|---|---|
committer | Kim Alvefur <zash@zash.se> | 2020-05-05 22:21:39 +0200 |
commit | d146cc6f582196d9d9a79b6d3c2bf030cc26f7b2 (patch) | |
tree | 11602e606c0142e3e21d1e665b21d60b824873a4 /plugins/mod_muc_mam.lua | |
parent | 8055c8f7d721ba1d8aa538255e61a1830377c49e (diff) | |
download | prosody-d146cc6f582196d9d9a79b6d3c2bf030cc26f7b2.tar.gz prosody-d146cc6f582196d9d9a79b6d3c2bf030cc26f7b2.zip |
MAM: Remove 1% of contents when reaching limits, fix #1545
With mod\_storage\_internal this counts out to 100 messages out of 10 000,
meaning should not hit the quota limit immediately until that many
messages have been added again.
Diffstat (limited to 'plugins/mod_muc_mam.lua')
-rw-r--r-- | plugins/mod_muc_mam.lua | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/plugins/mod_muc_mam.lua b/plugins/mod_muc_mam.lua index 7eeada6d..a151931f 100644 --- a/plugins/mod_muc_mam.lua +++ b/plugins/mod_muc_mam.lua @@ -54,6 +54,7 @@ local archive_store = "muc_log"; local archive = module:open_store(archive_store, "archive"); local archive_item_limit = module:get_option_number("storage_archive_item_limit", archive.caps and archive.caps.quota or 1000); +local archive_truncate = math.floor(archive_item_limit * 0.99); if archive.name == "null" or not archive.find then if not archive.find then @@ -397,7 +398,7 @@ local function save_to_history(self, stanza) if not id and (archive.caps and archive.caps.truncate) then module:log("debug", "User '%s' over quota, truncating archive", room_node); local truncated = archive:delete(room_node, { - truncate = archive_item_limit - 1; + truncate = archive_truncate; }); if truncated then id, err = archive:append(room_node, nil, stored_stanza, time, with); |