Mercurial > prosody-hg
comparison plugins/mod_privacy.lua @ 2614:7a589e9e2372
mod_privacy: Upgrade old privacy lists to new storage format, so they don't get lost
| author | Matthew Wild <mwild1@gmail.com> |
|---|---|
| date | Fri, 12 Feb 2010 12:07:46 +0000 |
| parents | 2d7e2a28d1d5 |
| children | c5f7c803fe7d |
comparison
equal
deleted
inserted
replaced
| 2613:afa20941e098 | 2614:7a589e9e2372 |
|---|---|
| 301 local origin, stanza = data.origin, data.stanza; | 301 local origin, stanza = data.origin, data.stanza; |
| 302 | 302 |
| 303 if stanza.attr.to == nil then -- only service requests to own bare JID | 303 if stanza.attr.to == nil then -- only service requests to own bare JID |
| 304 local query = stanza.tags[1]; -- the query element | 304 local query = stanza.tags[1]; -- the query element |
| 305 local valid = false; | 305 local valid = false; |
| 306 local privacy_lists = datamanager.load(origin.username, origin.host, "privacy") or {}; | 306 local privacy_lists = datamanager.load(origin.username, origin.host, "privacy") or { lists = {} }; |
| 307 | |
| 308 if privacy_lists.lists[1] then -- Code to migrate from old privacy lists format, remove in 0.8 | |
| 309 module:log("info", "Upgrading format of stored privacy lists for %s@%s", origin.username, origin.host); | |
| 310 local lists = privacy_lists.lists; | |
| 311 for idx, list in ipairs(lists) do | |
| 312 lists[list.name] = list; | |
| 313 lists[idx] = nil; | |
| 314 end | |
| 315 end | |
| 307 | 316 |
| 308 if stanza.attr.type == "set" then | 317 if stanza.attr.type == "set" then |
| 309 if #query.tags == 1 then -- the <query/> element MUST NOT include more than one child element | 318 if #query.tags == 1 then -- the <query/> element MUST NOT include more than one child element |
| 310 for _,tag in ipairs(query.tags) do | 319 for _,tag in ipairs(query.tags) do |
| 311 if tag.name == "active" or tag.name == "default" then | 320 if tag.name == "active" or tag.name == "default" then |
