# HG changeset patch # User Matthew Wild # Date 1586619837 -3600 # Node ID 38159b9adf9f16ad86ea711797489391730994a9 # Parent dc24a8783c5d83c2bc320413f09f7f9e60285a60 MUC: Add API for adding 'filtered namespaces' to be stripped from inbound presence diff -r dc24a8783c5d -r 38159b9adf9f plugins/muc/util.lib.lua --- 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)