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 | c439358e74c1c970efba55a317a7e6b65d0c38af (patch) | |
tree | e1a376050cf210588e2abf6b142d7dba9412c37e /plugins/muc/util.lib.lua | |
parent | 007c8b7e64a93a79684b62d8ec888fe2fe1100e4 (diff) | |
download | prosody-c439358e74c1c970efba55a317a7e6b65d0c38af.tar.gz prosody-c439358e74c1c970efba55a317a7e6b65d0c38af.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) |