aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthew Wild <mwild1@gmail.com>2010-02-12 12:07:46 +0000
committerMatthew Wild <mwild1@gmail.com>2010-02-12 12:07:46 +0000
commitc68c3797aa8ae689ffa946bf9a2eefcd0ee0fd40 (patch)
tree93ff3199ab1a7b2e444097399ef182ebac6c2dc7
parent1445574fd32de84b735e4d324ad9a6864b26ba57 (diff)
downloadprosody-c68c3797aa8ae689ffa946bf9a2eefcd0ee0fd40.tar.gz
prosody-c68c3797aa8ae689ffa946bf9a2eefcd0ee0fd40.zip
mod_privacy: Upgrade old privacy lists to new storage format, so they don't get lost
-rw-r--r--plugins/mod_privacy.lua11
1 files changed, 10 insertions, 1 deletions
diff --git a/plugins/mod_privacy.lua b/plugins/mod_privacy.lua
index d6ff9761..1cb931e0 100644
--- a/plugins/mod_privacy.lua
+++ b/plugins/mod_privacy.lua
@@ -303,7 +303,16 @@ module:hook("iq/bare/jabber:iq:privacy:query", function(data)
if stanza.attr.to == nil then -- only service requests to own bare JID
local query = stanza.tags[1]; -- the query element
local valid = false;
- local privacy_lists = datamanager.load(origin.username, origin.host, "privacy") or {};
+ local privacy_lists = datamanager.load(origin.username, origin.host, "privacy") or { lists = {} };
+
+ if privacy_lists.lists[1] then -- Code to migrate from old privacy lists format, remove in 0.8
+ module:log("info", "Upgrading format of stored privacy lists for %s@%s", origin.username, origin.host);
+ local lists = privacy_lists.lists;
+ for idx, list in ipairs(lists) do
+ lists[list.name] = list;
+ lists[idx] = nil;
+ end
+ end
if stanza.attr.type == "set" then
if #query.tags == 1 then -- the <query/> element MUST NOT include more than one child element