1 local verse = require "verse"; |
1 local verse = require "verse"; |
2 |
2 |
3 local xmlns_carbons = "urn:xmpp:carbons:1"; |
3 local xmlns_carbons = "urn:xmpp:carbons:2"; |
4 local xmlns_forward = "urn:xmpp:forward:0"; |
4 local xmlns_forward = "urn:xmpp:forward:0"; |
5 local os_time = os.time; |
5 local os_time = os.time; |
6 local parse_datetime = require "util.datetime".parse; |
6 local parse_datetime = require "util.datetime".parse; |
7 local bare_jid = require "util.jid".bare; |
7 local bare_jid = require "util.jid".bare; |
8 |
8 |
45 stream:hook("bind-success", function() |
45 stream:hook("bind-success", function() |
46 my_bare = bare_jid(stream.jid); |
46 my_bare = bare_jid(stream.jid); |
47 end); |
47 end); |
48 |
48 |
49 stream:hook("message", function(stanza) |
49 stream:hook("message", function(stanza) |
50 local carbon_dir = stanza:get_child(nil, xmlns_carbons); |
50 local carbon = stanza:get_child(nil, xmlns_carbons); |
51 if stanza.attr.from == my_bare and carbon_dir then |
51 if stanza.attr.from == my_bare and carbon then |
52 carbon_dir = carbon_dir.name; |
52 local carbon_dir = carbon.name; |
53 local fwd = stanza:get_child("forwarded", xmlns_forward); |
53 local fwd = carbon:get_child("forwarded", xmlns_forward); |
54 local fwd_stanza = fwd and fwd:get_child("message", "jabber:client"); |
54 local fwd_stanza = fwd and fwd:get_child("message", "jabber:client"); |
55 local delay = fwd:get_child("delay", "urn:xmpp:delay"); |
55 local delay = fwd:get_child("delay", "urn:xmpp:delay"); |
56 local stamp = delay and delay.attr.stamp; |
56 local stamp = delay and delay.attr.stamp; |
57 stamp = stamp and parse_datetime(stamp); |
57 stamp = stamp and parse_datetime(stamp); |
58 if fwd_stanza then |
58 if fwd_stanza then |