# HG changeset patch # User Kim Alvefur # Date 1347754687 -7200 # Node ID e8253c93116626cb489195a39b9aff61df691d7a # Parent 834ab74585ec0a6126de7d07697c25019754f811 storagemanager: Add purge() for purging user data from all backends in use diff -r 834ab74585ec -r e8253c931166 core/storagemanager.lua --- a/core/storagemanager.lua Sat Sep 15 23:00:59 2012 +0200 +++ b/core/storagemanager.lua Sun Sep 16 02:18:07 2012 +0200 @@ -94,6 +94,25 @@ return ret, err; end +function purge(user, host) + local storage = config.get(host, "core", "storage"); + local driver_name; + if type(storage) == "table" then + -- multiple storage backends in use that we need to purge + local purged = {}; + for store, driver in pairs(storage) do + if not purged[driver] then + purged[driver] = get_driver(host, store):purge(user); + end + end + end + get_driver(host):purge(user); -- and the default driver + + olddm.purge(user, host); -- COMPAT list stores, like offline messages end up in the old datamanager + + return true; +end + function datamanager.load(username, host, datastore) return open(host, datastore):get(username); end @@ -104,7 +123,7 @@ return get_driver(host):list_stores(username); end function datamanager.purge(username, host) - return get_driver(host):purge(username); + return purge(username); end return _M; diff -r 834ab74585ec -r e8253c931166 core/usermanager.lua --- a/core/usermanager.lua Sat Sep 15 23:00:59 2012 +0200 +++ b/core/usermanager.lua Sun Sep 16 02:18:07 2012 +0200 @@ -93,7 +93,7 @@ local ok, err = hosts[host].users.delete_user(username); if not ok then return nil, err; end prosody.events.fire_event("user-deleted", { username = username, host = host }); - return storagemanager.get_driver(host):purge(username); + return storagemanager.purge(username, host); end function get_sasl_handler(host, session)