Mercurial > prosody-modules
diff mod_storage_s3/mod_storage_s3.lua @ 5697:4a0279c5c7ed
mod_storage_s3: Implement archive store deletion
Not the most efficient way but should work.
author | Kim Alvefur <zash@zash.se> |
---|---|
date | Sat, 11 Nov 2023 22:47:14 +0100 |
parents | 66986f5271c3 |
children | 991fb904fa49 |
line wrap: on
line diff
--- a/mod_storage_s3/mod_storage_s3.lua Sat Nov 11 22:26:39 2023 +0100 +++ b/mod_storage_s3/mod_storage_s3.lua Sat Nov 11 22:47:14 2023 +0100 @@ -8,6 +8,7 @@ local it = require "prosody.util.iterators"; local jid = require "prosody.util.jid"; local json = require "prosody.util.json"; +local promise = require "prosody.util.promise"; local st = require "prosody.util.stanza"; local xml = require "prosody.util.xml"; local url = require "socket.url"; @@ -309,10 +310,14 @@ return it.unique(keyval.users(self)); end ---[[ TODO +local function count(t) local n = 0; for _ in pairs(t) do n = n + 1; end return n; end + function archive:delete(username, query) - return nil, "not-implemented"; + local deletions = {}; + for key, _, when, with in self:find(username, query) do + deletions[key] = new_request(self, "DELETE", self:_path(username or "@", dt.date(when), nil, with, key)); + end + return async.wait_for(promise.all(deletions):next(count)); end ---]] module:provides("storage", driver);