Changeset

10713:38159b9adf9f

MUC: Add API for adding 'filtered namespaces' to be stripped from inbound presence
author Matthew Wild <mwild1@gmail.com>
date Sat, 11 Apr 2020 16:43:57 +0100
parents 10712:dc24a8783c5d
children 10714:9ecad2304297
files plugins/muc/util.lib.lua
diffstat 1 files changed, 11 insertions(+), 7 deletions(-) [+]
line wrap: on
line diff
--- a/plugins/muc/util.lib.lua	Sat Apr 11 16:41:52 2020 +0100
+++ b/plugins/muc/util.lib.lua	Sat Apr 11 16:43:57 2020 +0100
@@ -41,18 +41,22 @@
 	return kickable_error_conditions[cond];
 end
 
-local muc_x_filters = {
-	["http://jabber.org/protocol/muc"] = true;
-	["http://jabber.org/protocol/muc#user"] = true;
-}
-local function muc_x_filter(tag)
-	if muc_x_filters[tag.attr.xmlns] then
+local filtered_namespaces = module:shared("filtered-namespaces");
+filtered_namespaces["http://jabber.org/protocol/muc"] = true;
+filtered_namespaces["http://jabber.org/protocol/muc#user"] = true;
+
+local function muc_ns_filter(tag)
+	if filtered_namespaces[tag.attr.xmlns] then
 		return nil;
 	end
 	return tag;
 end
 function _M.filter_muc_x(stanza)
-	return stanza:maptags(muc_x_filter);
+	return stanza:maptags(muc_ns_filter);
+end
+
+function _M.add_filtered_namespace(xmlns)
+	filtered_namespaces[xmlns] = true;
 end
 
 function _M.only_with_min_role(role)