Changeset

7775:3733bdbe0b22

mod_blocklist: Check first level cache before calling blocklist getter
author Kim Alvefur <zash@zash.se>
date Mon, 05 Dec 2016 17:35:38 +0100
parents 7774:1f55edac1f72
children 7776:63f50a84318f
files plugins/mod_blocklist.lua
diffstat 1 files changed, 3 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/plugins/mod_blocklist.lua	Thu Dec 08 18:06:18 2016 +0100
+++ b/plugins/mod_blocklist.lua	Mon Dec 05 17:35:38 2016 +0100
@@ -77,10 +77,7 @@
 end
 
 local function get_blocklist(username)
-	local blocklist = cache[username];
-	if not blocklist then
-		blocklist = cache2:get(username);
-	end
+	local blocklist = cache2:get(username);
 	if not blocklist then
 		if not user_exists(username, module.host) then
 			return null_blocklist;
@@ -102,7 +99,7 @@
 	local origin, stanza = event.origin, event.stanza;
 	local username = origin.username;
 	local reply = st.reply(stanza):tag("blocklist", { xmlns = "urn:xmpp:blocking" });
-	local blocklist = get_blocklist(username);
+	local blocklist = cache[username] or get_blocklist(username);
 	for jid in pairs(blocklist) do
 		if jid then
 			reply:tag("item", { jid = jid }):up();
@@ -156,7 +153,7 @@
 		return true;
 	end
 
-	local blocklist = get_blocklist(username);
+	local blocklist = cache[username] or get_blocklist(username);
 
 	local new_blocklist = {
 		-- We set the [false] key to someting as a signal not to migrate privacy lists