diff mod_storage_xmlarchive/mod_storage_xmlarchive.lua @ 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 152439ca92ee
children 004d3bfc05ea
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);