aboutsummaryrefslogtreecommitdiffstats
path: root/plugins
diff options
context:
space:
mode:
authorKim Alvefur <zash@zash.se>2015-12-06 02:32:16 +0100
committerKim Alvefur <zash@zash.se>2015-12-06 02:32:16 +0100
commit589b736095eb90220ebfeaa3c091c4bd7cec0924 (patch)
tree90399654301647d194af270fa1ac14fd8d50d4c9 /plugins
parent7c2da2da9f71323ebfc5791582ac53f0255a1e4e (diff)
downloadprosody-589b736095eb90220ebfeaa3c091c4bd7cec0924.tar.gz
prosody-589b736095eb90220ebfeaa3c091c4bd7cec0924.zip
mod_blocklist: Skip creating some tables and some processing if unblocking
Diffstat (limited to 'plugins')
-rw-r--r--plugins/mod_blocklist.lua17
1 files changed, 9 insertions, 8 deletions
diff --git a/plugins/mod_blocklist.lua b/plugins/mod_blocklist.lua
index d7476cb5..8bcd7700 100644
--- a/plugins/mod_blocklist.lua
+++ b/plugins/mod_blocklist.lua
@@ -121,6 +121,7 @@ local function edit_blocklist(event)
local origin, stanza = event.origin, event.stanza;
local username = origin.username;
local action = stanza.tags[1]; -- "block" or "unblock"
+ local is_blocking = action.name == "block" or nil; -- nil if unblocking
local new = {}; -- JIDs to block depending or unblock on action
-- XEP-0191 sayeth:
@@ -128,11 +129,11 @@ local function edit_blocklist(event)
-- > server MUST send unavailable presence information to the contact (but
-- > only if the contact is allowed to receive presence notifications [...]
-- So contacts we need to do that for are added to the set below.
- local send_unavailable = {};
+ local send_unavailable = is_blocking and {};
-- Because blocking someone currently also blocks the ability to reject
-- subscription requests, we'll preemptively reject such
- local remove_pending = {};
+ local remove_pending = is_blocking and {};
for item in action:childtags("item") do
local jid = jid_prep(item.attr.jid);
@@ -142,15 +143,15 @@ local function edit_blocklist(event)
end
item.attr.jid = jid; -- echo back prepped
new[jid] = true;
- if is_contact_subscribed(username, module.host, jid) then
- send_unavailable[jid] = true;
- elseif is_contact_pending_in(username, module.host, jid) then
- remove_pending[jid] = true;
+ if is_blocking then
+ if is_contact_subscribed(username, module.host, jid) then
+ send_unavailable[jid] = true;
+ elseif is_contact_pending_in(username, module.host, jid) then
+ remove_pending[jid] = true;
+ end
end
end
- local is_blocking = action.name == "block" or nil; -- nil if unblocking
-
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"));