Comparison

plugins/mod_blocklist.lua @ 7774:1f55edac1f72

mod_blocklist: Simplify loop with ipairs
author Kim Alvefur <zash@zash.se>
date Thu, 08 Dec 2016 18:06:18 +0100
parent 7773:7fd26815fcf6
child 7775:3733bdbe0b22
comparison
equal deleted inserted replaced
7773:7fd26815fcf6 7774:1f55edac1f72
60 if not default_list or not default_list.items then return; end 60 if not default_list or not default_list.items then return; end
61 61
62 local migrated_data = { [false] = { created = os.time(); migrated = "privacy" }}; 62 local migrated_data = { [false] = { created = os.time(); migrated = "privacy" }};
63 63
64 module:log("info", "Migrating blocklist from mod_privacy storage for user '%s'", username); 64 module:log("info", "Migrating blocklist from mod_privacy storage for user '%s'", username);
65 local item, jid; 65 for _, item in ipairs(default_list.items) do
66 for i = 1, #legacy_data do
67 item = legacy_data[i];
68 if item.type == "jid" and item.action == "deny" then 66 if item.type == "jid" and item.action == "deny" then
69 jid = jid_prep(item.value); 67 local jid = jid_prep(item.value);
70 if not jid then 68 if not jid then
71 module:log("warn", "Invalid JID in privacy store for user '%s' not migrated: %s", username, tostring(item.value)); 69 module:log("warn", "Invalid JID in privacy store for user '%s' not migrated: %s", username, tostring(item.value));
72 else 70 else
73 migrated_data[jid] = true; 71 migrated_data[jid] = true;
74 end 72 end