# HG changeset patch # User Matthew Wild # Date 1408964632 -3600 # Node ID 02cd4a081db44e4bbae8ced0d7ce4918064da9c4 # Parent d5e8758d391d28d9925fd4ef3b3151524fd82970 mod_filter_chatstates: Replace unwanted messages with a dummy stanza so that mod_message doesn't think delivery failed (and then generate an error reply) diff -r d5e8758d391d -r 02cd4a081db4 mod_filter_chatstates/mod_filter_chatstates.lua --- a/mod_filter_chatstates/mod_filter_chatstates.lua Mon Aug 25 00:38:14 2014 +0200 +++ b/mod_filter_chatstates/mod_filter_chatstates.lua Mon Aug 25 12:03:52 2014 +0100 @@ -1,6 +1,9 @@ local filters = require "util.filters"; local st = require "util.stanza"; +local dummy_stanza_mt = setmetatable({ __tostring = function () return ""; end }, { __index = st.stanza_mt }); +local dummy_stanza = setmetatable(st.stanza(), dummy_stanza_mt); + module:depends("csi"); local function filter_chatstates(stanza) @@ -8,11 +11,11 @@ stanza = st.clone(stanza); stanza:maptags(function (tag) if tag.attr.xmlns ~= "http://jabber.org/protocol/chatstates" then - return tag + return tag; end end); if #stanza.tags == 0 then - return nil; + return dummy_stanza; end end return stanza;