comparison mod_filter_chatstates/mod_filter_chatstates.lua @ 1767:ca48eea4785c

mod_filter_chatstates: Backout 02cd4a081db4; no longer required due to changes in mod_smacks
author Kim Alvefur <zash@zash.se>
date Mon, 08 Jun 2015 15:29:33 +0200
parents 02cd4a081db4
children 23b3c8e294d2
comparison
equal deleted inserted replaced
1766:e4c3d335b07f 1767:ca48eea4785c
1 local filters = require "util.filters"; 1 local filters = require "util.filters";
2 local st = require "util.stanza"; 2 local st = require "util.stanza";
3
4 local dummy_stanza_mt = setmetatable({ __tostring = function () return ""; end }, { __index = st.stanza_mt });
5 local dummy_stanza = setmetatable(st.stanza(), dummy_stanza_mt);
6 3
7 module:depends("csi"); 4 module:depends("csi");
8 5
9 local function filter_chatstates(stanza) 6 local function filter_chatstates(stanza)
10 if stanza.name == "message" then 7 if stanza.name == "message" then
11 stanza = st.clone(stanza); 8 stanza = st.clone(stanza);
12 stanza:maptags(function (tag) 9 stanza:maptags(function (tag)
13 if tag.attr.xmlns ~= "http://jabber.org/protocol/chatstates" then 10 if tag.attr.xmlns ~= "http://jabber.org/protocol/chatstates" then
14 return tag; 11 return tag
15 end 12 end
16 end); 13 end);
17 if #stanza.tags == 0 then 14 if #stanza.tags == 0 then
18 return dummy_stanza; 15 return nil;
19 end 16 end
20 end 17 end
21 return stanza; 18 return stanza;
22 end 19 end
23 20