# HG changeset patch # User Matthew Wild # Date 1452696979 0 # Node ID c769ed3e5b2bc67a1be02dc4adabae85c0b0c2f5 # Parent 41fd55eba4a80b5032a05c244230179ac45c956b mod_block_outgoing: Make admins exempt from restrictions diff -r 41fd55eba4a8 -r c769ed3e5b2b mod_block_outgoing/mod_block_outgoing.lua --- a/mod_block_outgoing/mod_block_outgoing.lua Wed Jan 13 14:26:44 2016 +0000 +++ b/mod_block_outgoing/mod_block_outgoing.lua Wed Jan 13 14:56:19 2016 +0000 @@ -1,6 +1,7 @@ -- Module to block all outgoing stanzas from a list of users local jid_bare = require "util.jid".bare; +local is_admin = require "core.usermanager".is_admin; local block_users = module:get_option_set("block_outgoing_users", {}); local block_all = block_users:empty(); @@ -10,10 +11,11 @@ local function block_stanza(event) local stanza = event.stanza; - if stanza.attr.to == nil then + local from_jid = jid_bare(stanza.attr.from); + if stanza.attr.to == nil or is_admin(from_jid, module.host) then return; end - if block_all or block_users:contains(jid_bare(stanza.attr.from)) then + if block_all or block_users:contains(from_jid) then module:log("debug", "Blocked outgoing %s stanza from %s", stanza.name, stanza.attr.from); return true; end