# HG changeset patch
# User daurnimator <quae@daurnimator.com>
# Date 1402002434 14400
# Node ID 006b0e0f0de26fa74283c63e237cad9a93adf8ab
# Parent  ee2d5b2a263d3728a2c5920ff1660f6f7c9e7a1d
plugins/muc: Move 'x' filtering from occupant to util

diff -r ee2d5b2a263d -r 006b0e0f0de2 plugins/muc/occupant.lib.lua
--- 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 = {};
diff -r ee2d5b2a263d -r 006b0e0f0de2 plugins/muc/util.lib.lua
--- 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;