aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKim Alvefur <zash@zash.se>2017-03-31 17:48:50 +0200
committerKim Alvefur <zash@zash.se>2017-03-31 17:48:50 +0200
commit8be8224bbacc9de5cfbb11a566c85aa2eca1f8dc (patch)
tree51c1b0c5b09310230e3cca631d81ab38807fa267
parentffb3266efa026dde9275728a06224f2c7814fcba (diff)
downloadprosody-8be8224bbacc9de5cfbb11a566c85aa2eca1f8dc.tar.gz
prosody-8be8224bbacc9de5cfbb11a566c85aa2eca1f8dc.zip
mod_storage_internal: Add support for removing archived items
-rw-r--r--plugins/mod_storage_internal.lua19
1 files changed, 19 insertions, 0 deletions
diff --git a/plugins/mod_storage_internal.lua b/plugins/mod_storage_internal.lua
index a5401f70..c1e460eb 100644
--- a/plugins/mod_storage_internal.lua
+++ b/plugins/mod_storage_internal.lua
@@ -120,4 +120,23 @@ function archive:find(username, query)
end, count;
end
+function archive:delete(username, query)
+ if not query or next(query) == nil then
+ return datamanager.list_store(username, host, self.store, nil);
+ end
+ for k in pairs(query) do
+ if k ~= "end" then return nil, "unsupported-query-field"; end
+ end
+ local items, err = datamanager.list_load(username, host, self.store);
+ if not items then return items, err; end
+ items = array(items);
+ items:filter(function (item)
+ return item.when > query["end"];
+ end);
+ local count = #items;
+ local ok, err = datamanager.list_store(username, host, self.store, items);
+ if not ok then return ok, err; end
+ return count;
+end
+
module:provides("storage", driver);