Software /
code /
prosody-modules
Changeset
1494:02cd4a081db4
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)
author | Matthew Wild <mwild1@gmail.com> |
---|---|
date | Mon, 25 Aug 2014 12:03:52 +0100 |
parents | 1493:d5e8758d391d |
children | 1495:9a1b3f0d0939 |
files | mod_filter_chatstates/mod_filter_chatstates.lua |
diffstat | 1 files changed, 5 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- 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;