# HG changeset patch # User Matthew Wild # Date 1265976466 0 # Node ID 7a589e9e237232bf195747654f41311ff7dbd4db # Parent afa20941e0989033a7e6416f7f676e055758a2e7 mod_privacy: Upgrade old privacy lists to new storage format, so they don't get lost diff -r afa20941e098 -r 7a589e9e2372 plugins/mod_privacy.lua --- a/plugins/mod_privacy.lua Fri Feb 12 04:30:17 2010 +0500 +++ b/plugins/mod_privacy.lua Fri Feb 12 12:07:46 2010 +0000 @@ -303,7 +303,16 @@ 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 element MUST NOT include more than one child element