aboutsummaryrefslogtreecommitdiffstats
path: root/plugins/mod_blocklist.lua
diff options
context:
space:
mode:
authorKim Alvefur <zash@zash.se>2016-12-05 17:22:12 +0100
committerKim Alvefur <zash@zash.se>2016-12-05 17:22:12 +0100
commit12325f7354c8899596b32d8aa41e87d62eefbf0b (patch)
treef4977e435d159b0f51e33d585431d95c78f92c6c /plugins/mod_blocklist.lua
parent6280a047f6766dbf0423b5e76107d5c624f96e54 (diff)
downloadprosody-12325f7354c8899596b32d8aa41e87d62eefbf0b.tar.gz
prosody-12325f7354c8899596b32d8aa41e87d62eefbf0b.zip
mod_blocklist: Return early from migration if no valid privacy list data is found
Diffstat (limited to 'plugins/mod_blocklist.lua')
-rw-r--r--plugins/mod_blocklist.lua16
1 files changed, 9 insertions, 7 deletions
diff --git a/plugins/mod_blocklist.lua b/plugins/mod_blocklist.lua
index f0b305d6..e2dd8117 100644
--- a/plugins/mod_blocklist.lua
+++ b/plugins/mod_blocklist.lua
@@ -54,14 +54,13 @@ end
-- Migrates from the old mod_privacy storage
local function migrate_privacy_list(username)
- local migrated_data = { [false] = { created = os.time(); migrated = "privacy" }};
local legacy_data = module:open_store("privacy"):get(username);
- if legacy_data and legacy_data.lists and legacy_data.default then
- legacy_data = legacy_data.lists[legacy_data.default];
- legacy_data = legacy_data and legacy_data.items;
- else
- return migrated_data;
- end
+ if not legacy_data or not legacy_data.lists or not legacy_data.default then return; end
+ local default_list = legacy_data.lists[legacy_data.default];
+ if not default_list or not default_list.items then return; end
+
+ local migrated_data = { [false] = { created = os.time(); migrated = "privacy" }};
+
if legacy_data then
module:log("info", "Migrating blocklist from mod_privacy storage for user '%s'", username);
local item, jid;
@@ -94,6 +93,9 @@ local function get_blocklist(username)
if not blocklist then
blocklist = migrate_privacy_list(username);
end
+ if not blocklist then
+ blocklist = { [false] = { created = os.time(); }; };
+ end
cache2:set(username, blocklist);
end
cache[username] = blocklist;