aboutsummaryrefslogtreecommitdiffstats
path: root/plugins/muc
diff options
context:
space:
mode:
authorMatthew Wild <mwild1@gmail.com>2013-05-21 09:57:36 +0100
committerMatthew Wild <mwild1@gmail.com>2013-05-21 09:57:36 +0100
commit719dba768b24f8179d0fa47d5d046127bceb3242 (patch)
tree4781114cea19ba9939aea4dea5abad8711ed4563 /plugins/muc
parentefe217c73fdae21c90ab0c5533f6829f36b6a274 (diff)
downloadprosody-719dba768b24f8179d0fa47d5d046127bceb3242.tar.gz
prosody-719dba768b24f8179d0fa47d5d046127bceb3242.zip
mod_muc: Use stanza:maptags() instead of custom filtering functions, 7 insertions, 19 deletions!
Diffstat (limited to 'plugins/muc')
-rw-r--r--plugins/muc/muc.lib.lua26
1 files changed, 7 insertions, 19 deletions
diff --git a/plugins/muc/muc.lib.lua b/plugins/muc/muc.lib.lua
index 4867b941..4c398b57 100644
--- a/plugins/muc/muc.lib.lua
+++ b/plugins/muc/muc.lib.lua
@@ -27,28 +27,16 @@ local muc_domain = nil; --module:get_host();
local default_history_length, max_history_length = 20, math.huge;
------------
-local function filter_xmlns_from_array(array, filters)
- local count = 0;
- for i=#array,1,-1 do
- local attr = array[i].attr;
- if filters[attr and attr.xmlns] then
- t_remove(array, i);
- count = count + 1;
- end
- end
- return count;
-end
-local function filter_xmlns_from_stanza(stanza, filters)
- if filters then
- if filter_xmlns_from_array(stanza.tags, filters) ~= 0 then
- return stanza, filter_xmlns_from_array(stanza, filters);
- end
+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 stanza, 0;
+ return tag;
end
-local presence_filters = {["http://jabber.org/protocol/muc"]=true;["http://jabber.org/protocol/muc#user"]=true};
+
local function get_filtered_presence(stanza)
- return filter_xmlns_from_stanza(st.clone(stanza):reset(), presence_filters);
+ return st.clone(stanza):maptags(presence_filter);
end
local kickable_error_conditions = {
["gone"] = true;