diff options
author | Kim Alvefur <zash@zash.se> | 2012-09-16 02:18:07 +0200 |
---|---|---|
committer | Kim Alvefur <zash@zash.se> | 2012-09-16 02:18:07 +0200 |
commit | 172562976cd1ef9395f8f6913d49f02d3ba3dba2 (patch) | |
tree | dd350c97b55e1c653748e56362cf9ba0db548f6e /core | |
parent | 7bd79e84faf2a483a68af613903cefa98f963e25 (diff) | |
download | prosody-172562976cd1ef9395f8f6913d49f02d3ba3dba2.tar.gz prosody-172562976cd1ef9395f8f6913d49f02d3ba3dba2.zip |
storagemanager: Add purge() for purging user data from all backends in use
Diffstat (limited to 'core')
-rw-r--r-- | core/storagemanager.lua | 21 | ||||
-rw-r--r-- | core/usermanager.lua | 2 |
2 files changed, 21 insertions, 2 deletions
diff --git a/core/storagemanager.lua b/core/storagemanager.lua index 1b76a394..a9759b6a 100644 --- a/core/storagemanager.lua +++ b/core/storagemanager.lua @@ -94,6 +94,25 @@ function open(host, store, typ) 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 @@ function datamanager.list_stores(username, host) 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 --git a/core/usermanager.lua b/core/usermanager.lua index 2ca0aef1..0ed61f23 100644 --- a/core/usermanager.lua +++ b/core/usermanager.lua @@ -93,7 +93,7 @@ function delete_user(username, host) 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) |