diff options
author | Matthew Wild <mwild1@gmail.com> | 2013-05-21 09:57:36 +0100 |
---|---|---|
committer | Matthew Wild <mwild1@gmail.com> | 2013-05-21 09:57:36 +0100 |
commit | aa37ade792246b8b91ec8958c81735ea8bbe4489 (patch) | |
tree | 4781114cea19ba9939aea4dea5abad8711ed4563 | |
parent | 93b9f09b8609020e5efb31b239acab60aa71ff08 (diff) | |
download | prosody-aa37ade792246b8b91ec8958c81735ea8bbe4489.tar.gz prosody-aa37ade792246b8b91ec8958c81735ea8bbe4489.zip |
mod_muc: Use stanza:maptags() instead of custom filtering functions, 7 insertions, 19 deletions!
-rw-r--r-- | plugins/muc/muc.lib.lua | 26 |
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; |