plugins/mod_blocklist.lua
changeset 6971 828a10e0464b
parent 6970 d90a4d6a0e2c
child 6972 31d8e1a8a014
--- a/plugins/mod_blocklist.lua	Sat Dec 05 22:46:50 2015 +0100
+++ b/plugins/mod_blocklist.lua	Sun Dec 06 02:07:15 2015 +0100
@@ -123,9 +123,9 @@
 		new[jid] = is_contact_subscribed(username, module.host, jid) or false;
 	end
 
-	local mode = action.name == "block" or nil;
+	local is_blocking = action.name == "block" or nil; -- nil if unblocking
 
-	if mode and not next(new) then
+	if is_blocking and not next(new) then
 		-- <block/> element does not contain at least one <item/> child element
 		origin.send(st_error_reply(stanza, "modify", "bad-request"));
 		return true;
@@ -135,12 +135,12 @@
 
 	local new_blocklist = {};
 
-	if mode or next(new) then
+	if is_blocking or next(new) then
 		for jid in pairs(blocklist) do
 			new_blocklist[jid] = true;
 		end
 		for jid in pairs(new) do
-			new_blocklist[jid] = mode;
+			new_blocklist[jid] = is_blocking;
 		end
 		-- else empty the blocklist
 	end
@@ -154,7 +154,7 @@
 		return true;
 	end
 
-	if mode then
+	if is_blocking then
 		for jid, in_roster in pairs(new) do
 			if not blocklist[jid] and in_roster and sessions[username] then
 				for _, session in pairs(sessions[username].sessions) do