# HG changeset patch # User Kim Alvefur # Date 1326226099 -3600 # Node ID a228f3c7808acd39751b58f54cfc641497ca5044 # Parent c5b7a4c717a64098e5f4b430449e507cd6d37dda plugins.carbons: Update to XEP v0.6. Check that messages are from your bare jid. diff -r c5b7a4c717a6 -r a228f3c7808a plugins/carbons.lua --- a/plugins/carbons.lua Fri Jan 06 16:54:10 2012 +0100 +++ b/plugins/carbons.lua Tue Jan 10 21:08:19 2012 +0100 @@ -4,6 +4,7 @@ local xmlns_forward = "urn:xmpp:forward:0"; local os_date = os.date; local datetime = function(t) return os_date("!%Y-%m-%dT%H:%M:%SZ", t); end +local bare_jid = require "util.jid".bare; -- TODO Check disco for support @@ -40,15 +41,18 @@ end or nil); end + local my_bare; + stream:hook("bind-success", function() + my_bare = bare_jid(stream.jid); + end); + stream:hook("message", function(stanza) - stream:debug(stanza); - local fwd = stanza:get_child("forwarded", xmlns_forward); - if fwd then - local carbon_dir = fwd:get_child(nil, xmlns_carbons); + local carbon_dir = fwd:get_child(nil, xmlns_carbons); + if stanza.attr.from == my_bare and carbon_dir then carbon_dir = carbon_dir and carbon_dir.name; - if carbon_dir then - local fwd_stanza = fwd:get_child("message", "jabber:client"); - assert(fwd_stanza, "No stanza included.\n"..tostring(stanza).."\n--\n"..tostring(fwd_stanza)); + local fwd = stanza:get_child("forwarded", xmlns_forward); + local fwd_stanza = fwd and fwd:get_child("message", "jabber:client"); + if fwd_stanza then return stream:event("carbon", { dir = carbon_dir, stanza = fwd_stanza,