aboutsummaryrefslogtreecommitdiffstats
path: root/plugins
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
commitaa37ade792246b8b91ec8958c81735ea8bbe4489 (patch)
tree4781114cea19ba9939aea4dea5abad8711ed4563 /plugins
parent93b9f09b8609020e5efb31b239acab60aa71ff08 (diff)
downloadprosody-aa37ade792246b8b91ec8958c81735ea8bbe4489.tar.gz
prosody-aa37ade792246b8b91ec8958c81735ea8bbe4489.zip
mod_muc: Use stanza:maptags() instead of custom filtering functions, 7 insertions, 19 deletions!
Diffstat (limited to 'plugins')
-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;