Diff

plugins/mod_blocklist.lua @ 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
parent 7774:1f55edac1f72
child 7968:f0e35f4db9e0
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