Software /
code /
prosody-modules
Changeset
1819:1b08597b5e6f
mod_storage_xmlarchive: Add support for purging (used when deleting users)
author | Kim Alvefur <zash@zash.se> |
---|---|
date | Wed, 02 Sep 2015 16:43:34 +0200 |
parents | 1818:8b7bca07f5c0 |
children | 1820:8de50be756e5 |
files | mod_storage_xmlarchive/mod_storage_xmlarchive.lua |
diffstat | 1 files changed, 11 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/mod_storage_xmlarchive/mod_storage_xmlarchive.lua Tue Sep 01 17:55:02 2015 +0200 +++ b/mod_storage_xmlarchive/mod_storage_xmlarchive.lua Wed Sep 02 16:43:34 2015 +0200 @@ -224,4 +224,15 @@ return setmetatable({ store = store }, archive_mt); end +function provider:purge(username) + for store in dm.stores(username, module.host) do + local dates = dm.list_load(username, module.host, store) or empty; + if dates[1] and type(dates[1]) == "string" and dates[1]:match("^%d%d%d%d%-%d%d-%d%d$") then + module:log("info", "Store %s looks like an archive store, emptying it...", store); + provider:open(store, "archive"):delete(username); + end + end + return true; +end + module:provides("storage", provider);