Changeset

1866:58d96960ba8b

mod_filter_chatstates: Break out maptags filter into a stateless function
author Kim Alvefur <zash@zash.se>
date Mon, 21 Sep 2015 23:44:55 +0200
parents 1865:db8b256f51ff
children 1867:34468d3bfcac
files mod_filter_chatstates/mod_filter_chatstates.lua
diffstat 1 files changed, 7 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- 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