# HG changeset patch # User Kim Alvefur # Date 1442871895 -7200 # Node ID 58d96960ba8bc768e77e64c7047ada214575b52f # Parent db8b256f51ff592980b3025267bf385e32b9da73 mod_filter_chatstates: Break out maptags filter into a stateless function diff -r db8b256f51ff -r 58d96960ba8b mod_filter_chatstates/mod_filter_chatstates.lua --- a/mod_filter_chatstates/mod_filter_chatstates.lua Mon Sep 21 20:03:08 2015 +0200 +++ b/mod_filter_chatstates/mod_filter_chatstates.lua Mon Sep 21 23:44:55 2015 +0200 @@ -3,14 +3,16 @@ module:depends("csi"); +local function chatstate_tag_filter(tag) + if tag.attr.xmlns ~= "http://jabber.org/protocol/chatstates" then + return tag; + end +end + local function filter_chatstates(stanza) if stanza.name == "message" then stanza = st.clone(stanza); - stanza:maptags(function (tag) - if tag.attr.xmlns ~= "http://jabber.org/protocol/chatstates" then - return tag - end - end); + stanza:maptags(chatstate_tag_filter); if #stanza.tags == 0 then return ""; end