aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKim Alvefur <zash@zash.se>2022-10-17 15:20:06 +0200
committerKim Alvefur <zash@zash.se>2022-10-17 15:20:06 +0200
commit2269035c0dd4831975fa40ffeb0848a1ada478b5 (patch)
tree05d89abf7cfc3250fd51f8534ed64aa0c470eca7
parentaa8f7d1533ae86e6832a5a1ec506d58dee213d36 (diff)
downloadprosody-2269035c0dd4831975fa40ffeb0848a1ada478b5.tar.gz
prosody-2269035c0dd4831975fa40ffeb0848a1ada478b5.zip
mod_blocklist: Add option 'migrate_legacy_blocking' to disable migration from mod_privacy
Tiny performance improvement for new users by skipping this check. Most servers should have gone trough the migration for all active users long ago. As a suitable first step of phasing out this code, we make it possible to disable it first. Later it can be disabled by default, before finally the code is deleted.
-rw-r--r--CHANGES1
-rw-r--r--plugins/mod_blocklist.lua8
2 files changed, 9 insertions, 0 deletions
diff --git a/CHANGES b/CHANGES
index ea4ef9e0..12f67082 100644
--- a/CHANGES
+++ b/CHANGES
@@ -33,6 +33,7 @@ TRUNK
## Changes
- Support sub-second precision timestamps
+- mod_blocklist: New option 'migrate_legacy_blocking' to disable migration from mod_privacy
## Removed
diff --git a/plugins/mod_blocklist.lua b/plugins/mod_blocklist.lua
index dad06b62..13e98e00 100644
--- a/plugins/mod_blocklist.lua
+++ b/plugins/mod_blocklist.lua
@@ -54,6 +54,7 @@ local function set_blocklist(username, blocklist)
end
-- Migrates from the old mod_privacy storage
+-- TODO mod_privacy was removed in 0.10.0, this should be phased out
local function migrate_privacy_list(username)
local legacy_data = module:open_store("privacy"):get(username);
if not legacy_data or not legacy_data.lists or not legacy_data.default then return; end
@@ -77,6 +78,13 @@ local function migrate_privacy_list(username)
return migrated_data;
end
+if not module:get_option_boolean("migrate_legacy_blocking", true) then
+ migrate_privacy_list = function (username)
+ module:log("debug", "Migrating from mod_privacy disabled, user '%s' will start with a fresh blocklist", username);
+ return nil;
+ end
+end
+
local function get_blocklist(username)
local blocklist = cache2:get(username);
if not blocklist then