Mercurial > prosody-modules
changeset 2005:c769ed3e5b2b
mod_block_outgoing: Make admins exempt from restrictions
author | Matthew Wild <mwild1@gmail.com> |
---|---|
date | Wed, 13 Jan 2016 14:56:19 +0000 |
parents | 41fd55eba4a8 |
children | cb810a2bca47 |
files | mod_block_outgoing/mod_block_outgoing.lua |
diffstat | 1 files changed, 4 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- 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