Changeset

6271:006b0e0f0de2

plugins/muc: Move 'x' filtering from occupant to util
author daurnimator <quae@daurnimator.com>
date Thu, 05 Jun 2014 17:07:14 -0400
parents 6270:ee2d5b2a263d
children 6272:90054f21d1af
files plugins/muc/occupant.lib.lua plugins/muc/util.lib.lua
diffstat 2 files changed, 17 insertions(+), 14 deletions(-) [+]
line wrap: on
line diff
--- a/plugins/muc/occupant.lib.lua	Thu Jun 05 17:15:04 2014 -0400
+++ b/plugins/muc/occupant.lib.lua	Thu Jun 05 17:07:14 2014 -0400
@@ -2,21 +2,10 @@
 local pairs = pairs;
 local setmetatable = setmetatable;
 local st = require "util.stanza";
+local util = module:require "muc/util";
 
-local get_filtered_presence do
-	local presence_filters = {
-		["http://jabber.org/protocol/muc"] = true;
-		["http://jabber.org/protocol/muc#user"] = true;
-	}
-	local function presence_filter(tag)
-		if presence_filters[tag.attr.xmlns] then
-			return nil;
-		end
-		return tag;
-	end
-	function get_filtered_presence(stanza)
-		return st.clone(stanza):maptags(presence_filter);
-	end
+local function get_filtered_presence(stanza)
+	return util.filter_muc_x(st.clone(stanza));
 end
 
 local occupant_mt = {};
--- a/plugins/muc/util.lib.lua	Thu Jun 05 17:15:04 2014 -0400
+++ b/plugins/muc/util.lib.lua	Thu Jun 05 17:07:14 2014 -0400
@@ -41,4 +41,18 @@
 	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;