changeset 2007:dc1299ca0185

mod_block_outgoing: Make blocked stanza types configurable, and default to blocking messages only
author Matthew Wild <mwild1@gmail.com>
date Wed, 13 Jan 2016 23:04:55 +0000
parents cb810a2bca47
children cf3bdcb633f0
files mod_block_outgoing/mod_block_outgoing.lua
diffstat 1 files changed, 5 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/mod_block_outgoing/mod_block_outgoing.lua	Wed Jan 13 16:10:27 2016 +0000
+++ b/mod_block_outgoing/mod_block_outgoing.lua	Wed Jan 13 23:04:55 2016 +0000
@@ -2,12 +2,13 @@
 
 local jid_bare = require "util.jid".bare;
 local is_admin = require "core.usermanager".is_admin;
+local set = require "util.set";
 
 local block_users = module:get_option_set("block_outgoing_users", {});
 local block_all = block_users:empty();
 
-local stanza_types = { "iq", "presence", "message" };
-local jid_types = { "host", "bare", "full" };
+local stanza_types = module:get_option_set("block_outgoing_stanzas", { "message" });
+local jid_types = set.new{ "host", "bare", "full" };
 
 local function block_stanza(event)
 	local stanza = event.stanza;
@@ -22,8 +23,8 @@
 end
 
 function module.load()
-	for _, stanza_type in ipairs(stanza_types) do
-		for _, jid_type in ipairs(jid_types) do
+	for stanza_type in stanza_types do
+		for jid_type in jid_types do
 			module:hook("pre-"..stanza_type.."/"..jid_type, block_stanza, 10000);
 		end
 	end