Software /
code /
prosody
Diff
plugins/mod_csi_simple.lua @ 9911:ed011935c22d
mod_csi_simple: Break out stanza timestamping into a function for future reuse
author | Kim Alvefur <zash@zash.se> |
---|---|
date | Sun, 24 Mar 2019 18:32:50 +0100 |
parent | 9909:3229be01a08a |
child | 9912:601f9781a605 |
line wrap: on
line diff
--- a/plugins/mod_csi_simple.lua Sun Mar 24 18:30:51 2019 +0100 +++ b/plugins/mod_csi_simple.lua Sun Mar 24 18:32:50 2019 +0100 @@ -84,6 +84,14 @@ return true; end, -1); +local function with_timestamp(stanza, from) + if st.is_stanza(stanza) and stanza.attr.xmlns == nil and stanza.name ~= "iq" then + stanza = st.clone(stanza); + stanza:add_direct_child(st.stanza("delay", {xmlns = "urn:xmpp:delay", from = from, stamp = dt.datetime()})); + end + return stanza; +end + module:hook("csi-client-inactive", function (event) local session = event.origin; if session.conn and session.conn and session.conn.pause_writes then @@ -102,11 +110,7 @@ pump:flush(); send(stanza); else - if st.is_stanza(stanza) and stanza.attr.xmlns == nil and stanza.name ~= "iq" then - stanza = st.clone(stanza); - stanza:add_direct_child(st.stanza("delay", {xmlns = "urn:xmpp:delay", from = bare_jid, stamp = dt.datetime()})); - end - pump:push(stanza); + pump:push(with_timestamp(stanza, bare_jid)); end return true; end