diff options
author | Kim Alvefur <zash@zash.se> | 2017-03-31 17:48:50 +0200 |
---|---|---|
committer | Kim Alvefur <zash@zash.se> | 2017-03-31 17:48:50 +0200 |
commit | 2c3869f5be7a1a842438c207a60389f80eb75289 (patch) | |
tree | 51c1b0c5b09310230e3cca631d81ab38807fa267 /plugins/mod_storage_internal.lua | |
parent | 0e7993732b3552f05f93e6c8410e07a82ef91bfa (diff) | |
download | prosody-2c3869f5be7a1a842438c207a60389f80eb75289.tar.gz prosody-2c3869f5be7a1a842438c207a60389f80eb75289.zip |
mod_storage_internal: Add support for removing archived items
Diffstat (limited to 'plugins/mod_storage_internal.lua')
-rw-r--r-- | plugins/mod_storage_internal.lua | 19 |
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); |