plugins/mod_blocklist.lua
changeset 12779 1dd468c63a3d
parent 10115 0f335815244f
child 12981 74b9e05af71e
equal deleted inserted replaced
12778:fc4adc32a537 12779:1dd468c63a3d
    52 	cache[username] = blocklist;
    52 	cache[username] = blocklist;
    53 	return true;
    53 	return true;
    54 end
    54 end
    55 
    55 
    56 -- Migrates from the old mod_privacy storage
    56 -- Migrates from the old mod_privacy storage
       
    57 -- TODO mod_privacy was removed in 0.10.0, this should be phased out
    57 local function migrate_privacy_list(username)
    58 local function migrate_privacy_list(username)
    58 	local legacy_data = module:open_store("privacy"):get(username);
    59 	local legacy_data = module:open_store("privacy"):get(username);
    59 	if not legacy_data or not legacy_data.lists or not legacy_data.default then return; end
    60 	if not legacy_data or not legacy_data.lists or not legacy_data.default then return; end
    60 	local default_list = legacy_data.lists[legacy_data.default];
    61 	local default_list = legacy_data.lists[legacy_data.default];
    61 	if not default_list or not default_list.items then return; end
    62 	if not default_list or not default_list.items then return; end
    73 			end
    74 			end
    74 		end
    75 		end
    75 	end
    76 	end
    76 	set_blocklist(username, migrated_data);
    77 	set_blocklist(username, migrated_data);
    77 	return migrated_data;
    78 	return migrated_data;
       
    79 end
       
    80 
       
    81 if not module:get_option_boolean("migrate_legacy_blocking", true) then
       
    82 	migrate_privacy_list = function (username)
       
    83 		module:log("debug", "Migrating from mod_privacy disabled, user '%s' will start with a fresh blocklist", username);
       
    84 		return nil;
       
    85 	end
    78 end
    86 end
    79 
    87 
    80 local function get_blocklist(username)
    88 local function get_blocklist(username)
    81 	local blocklist = cache2:get(username);
    89 	local blocklist = cache2:get(username);
    82 	if not blocklist then
    90 	if not blocklist then