aboutsummaryrefslogtreecommitdiffstats
path: root/plugins/mod_storage_memory.lua
diff options
context:
space:
mode:
authorKim Alvefur <zash@zash.se>2019-03-20 12:14:45 +0100
committerKim Alvefur <zash@zash.se>2019-03-20 12:14:45 +0100
commit0681ffe60631d573ad8529de7eaa187cb21a20b1 (patch)
tree4db3457276fe8c67254636844548005c58a18c27 /plugins/mod_storage_memory.lua
parent9dce1de7674543e1daa3664c75a709845b1330fb (diff)
downloadprosody-0681ffe60631d573ad8529de7eaa187cb21a20b1.tar.gz
prosody-0681ffe60631d573ad8529de7eaa187cb21a20b1.zip
mod_storage_memory: Add support for archive item limits
Diffstat (limited to 'plugins/mod_storage_memory.lua')
-rw-r--r--plugins/mod_storage_memory.lua10
1 files changed, 10 insertions, 0 deletions
diff --git a/plugins/mod_storage_memory.lua b/plugins/mod_storage_memory.lua
index 745e394b..8e1cf879 100644
--- a/plugins/mod_storage_memory.lua
+++ b/plugins/mod_storage_memory.lua
@@ -8,6 +8,8 @@ local new_id = require "util.id".medium;
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.__index = archive_store;
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 @@ function archive_store:append(username, key, value, when, with)
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;