# HG changeset patch # User Thijs Alkemade # Date 1328142223 -3600 # Node ID db2a40cbd6ef7397098f78f596bb4e80ce1a2dd8 # Parent f9c73c1249cd6cfa5a5edb1da5949dac493ec833 Add a to stanzas that are queued (and don't have one already), so clients can show them with the original timestamp. diff -r f9c73c1249cd -r db2a40cbd6ef mod_smacks/mod_smacks.lua --- a/mod_smacks/mod_smacks.lua Thu Feb 02 01:23:00 2012 +0100 +++ b/mod_smacks/mod_smacks.lua Thu Feb 02 01:23:43 2012 +0100 @@ -7,9 +7,11 @@ local tonumber, tostring = tonumber, tostring; local add_filter = require "util.filters".add_filter; local timer = require "util.timer"; +local datetime = require "util.datetime"; local xmlns_sm = "urn:xmpp:sm:3"; local xmlns_errors = "urn:ietf:params:xml:ns:xmpp-stanzas"; +local xmlns_delay = "urn:xmpp:delay"; local sm_attr = { xmlns = xmlns_sm }; @@ -70,7 +72,13 @@ local function new_send(stanza) local attr = stanza.attr; if attr and not attr.xmlns then -- Stanza in default stream namespace - queue[#queue+1] = st.clone(stanza); + local cached_stanza = st.clone(stanza); + + if cached_stanza and cached_stanza:get_child("delay", xmlns_delay) == nil then + cached_stanza = cached_stanza:tag("delay", { xmlns = xmlns_delay, from = session.host, stamp = datetime.datetime()}); + end + + queue[#queue+1] = cached_stanza; end local ok, err = _send(stanza); if ok and #queue > max_unacked_stanzas and not session.awaiting_ack then