diff options
author | Kim Alvefur <zash@zash.se> | 2019-03-24 18:32:50 +0100 |
---|---|---|
committer | Kim Alvefur <zash@zash.se> | 2019-03-24 18:32:50 +0100 |
commit | e5885c928a79604dea999d24cf57104150b55898 (patch) | |
tree | 361be43377e9989e012daf835d56ff34dfbc624f /plugins/mod_csi_simple.lua | |
parent | 9e7035be7282a7902989904cec6aeec879814f49 (diff) | |
download | prosody-e5885c928a79604dea999d24cf57104150b55898.tar.gz prosody-e5885c928a79604dea999d24cf57104150b55898.zip |
mod_csi_simple: Break out stanza timestamping into a function for future reuse
Diffstat (limited to 'plugins/mod_csi_simple.lua')
-rw-r--r-- | plugins/mod_csi_simple.lua | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/plugins/mod_csi_simple.lua b/plugins/mod_csi_simple.lua index abe65fce..6bd6c0bf 100644 --- a/plugins/mod_csi_simple.lua +++ b/plugins/mod_csi_simple.lua @@ -84,6 +84,14 @@ module:hook("csi-is-stanza-important", function (event) 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 @@ module:hook("csi-client-inactive", function (event) 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 |