# HG changeset patch # User Kim Alvefur # Date 1553080485 -3600 # Node ID 69f8100148535824165b1af3c4baca7cd7972f58 # Parent 710a116341cdeea259f9473a6f1c535ffeb18984 mod_storage_memory: Add support for archive item limits diff -r 710a116341cd -r 69f810014853 plugins/mod_storage_memory.lua --- a/plugins/mod_storage_memory.lua Tue Nov 07 18:58:52 2017 +0100 +++ b/plugins/mod_storage_memory.lua Wed Mar 20 12:14:45 2019 +0100 @@ -8,6 +8,8 @@ local auto_purge_enabled = module:get_option_boolean("storage_memory_temporary", false); local auto_purge_stores = module:get_option_set("storage_memory_temporary_stores", {}); +local archive_item_limit = module:get_option_number("storage_archive_item_limit", 1000); + local memory = setmetatable({}, { __index = function(t, k) local store = module:shared(k) @@ -51,6 +53,12 @@ archive_store.users = _users; +archive_store.caps = { + total = true; + quota = archive_item_limit; + truncate = true; +}; + function archive_store:append(username, key, value, when, with) if is_stanza(value) then value = st.preserialize(value); @@ -70,6 +78,8 @@ end if a[key] then table.remove(a, a[key]); + elseif #a >= archive_item_limit then + return nil, "quota-limit"; end local i = #a+1; a[i] = v;