diff options
author | Matthew Wild <mwild1@gmail.com> | 2020-04-11 16:43:57 +0100 |
---|---|---|
committer | Matthew Wild <mwild1@gmail.com> | 2020-04-11 16:43:57 +0100 |
commit | a68413e51c2918db3bce9f3bcb3aa8fdd608ef73 (patch) | |
tree | e1a376050cf210588e2abf6b142d7dba9412c37e /plugins/muc/util.lib.lua | |
parent | 0bdf52fd9026c4f1925377f4f79012b401ccf562 (diff) | |
download | prosody-a68413e51c2918db3bce9f3bcb3aa8fdd608ef73.tar.gz prosody-a68413e51c2918db3bce9f3bcb3aa8fdd608ef73.zip |
MUC: Add API for adding 'filtered namespaces' to be stripped from inbound presence
Diffstat (limited to 'plugins/muc/util.lib.lua')
-rw-r--r-- | plugins/muc/util.lib.lua | 18 |
1 files changed, 11 insertions, 7 deletions
diff --git a/plugins/muc/util.lib.lua b/plugins/muc/util.lib.lua index 53a83fae..0877150f 100644 --- a/plugins/muc/util.lib.lua +++ b/plugins/muc/util.lib.lua @@ -41,18 +41,22 @@ function _M.is_kickable_error(stanza) 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) |