From 6a0d6594950e45d82e345da6a5cfb46d3664ec9d Mon Sep 17 00:00:00 2001 From: daurnimator Date: Thu, 3 Apr 2014 17:09:04 -0400 Subject: plugins/muc: Move valid_roles, valid_affiliations and is_kickable_error to new muc/util module --- plugins/muc/util.lib.lua | 44 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) create mode 100644 plugins/muc/util.lib.lua (limited to 'plugins/muc/util.lib.lua') diff --git a/plugins/muc/util.lib.lua b/plugins/muc/util.lib.lua new file mode 100644 index 00000000..90a3a183 --- /dev/null +++ b/plugins/muc/util.lib.lua @@ -0,0 +1,44 @@ +-- Prosody IM +-- Copyright (C) 2008-2010 Matthew Wild +-- Copyright (C) 2008-2010 Waqas Hussain +-- Copyright (C) 2014 Daurnimator +-- +-- This project is MIT/X11 licensed. Please see the +-- COPYING file in the source package for more information. +-- + +local _M = {}; + +_M.valid_affiliations = { + outcast = -1; + none = 0; + member = 1; + admin = 2; + owner = 3; +}; + +_M.valid_roles = { + none = 0; + visitor = 1; + participant = 2; + moderator = 3; +}; + +local kickable_error_conditions = { + ["gone"] = true; + ["internal-server-error"] = true; + ["item-not-found"] = true; + ["jid-malformed"] = true; + ["recipient-unavailable"] = true; + ["redirect"] = true; + ["remote-server-not-found"] = true; + ["remote-server-timeout"] = true; + ["service-unavailable"] = true; + ["malformed error"] = true; +}; +function _M.is_kickable_error(stanza) + local cond = select(2, stanza:get_error()) or "malformed error"; + return kickable_error_conditions[cond]; +end + +return _M; -- cgit v1.2.3 From 7fa36918b0198b806059172a6221f3e776cfde53 Mon Sep 17 00:00:00 2001 From: daurnimator Date: Thu, 5 Jun 2014 17:07:14 -0400 Subject: plugins/muc: Move 'x' filtering from occupant to util --- plugins/muc/util.lib.lua | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'plugins/muc/util.lib.lua') diff --git a/plugins/muc/util.lib.lua b/plugins/muc/util.lib.lua index 90a3a183..16deb543 100644 --- a/plugins/muc/util.lib.lua +++ b/plugins/muc/util.lib.lua @@ -41,4 +41,18 @@ 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 + return nil; + end + return tag; +end +function _M.filter_muc_x(stanza) + return stanza:maptags(muc_x_filter); +end + return _M; -- cgit v1.2.3