Software / code / prosody
Comparison
plugins/mod_smacks.lua @ 12045:a6c821720cb6
mod_smacks: Back out 48f8fa6cea7b - back in a86ae74da96c again
Maybe it works now with the session patching in the previous commit
| author | Kim Alvefur <zash@zash.se> |
|---|---|
| date | Mon, 13 Dec 2021 21:48:29 +0100 |
| parent | 12044:9eb1a178293e |
| child | 12046:372ec5cd0f51 |
comparison
equal
deleted
inserted
replaced
| 12044:9eb1a178293e | 12045:a6c821720cb6 |
|---|---|
| 196 local function outgoing_stanza_filter(stanza, session) | 196 local function outgoing_stanza_filter(stanza, session) |
| 197 -- XXX: Normally you wouldn't have to check the xmlns for a stanza as it's | 197 -- XXX: Normally you wouldn't have to check the xmlns for a stanza as it's |
| 198 -- supposed to be nil. | 198 -- supposed to be nil. |
| 199 -- However, when using mod_smacks with mod_websocket, then mod_websocket's | 199 -- However, when using mod_smacks with mod_websocket, then mod_websocket's |
| 200 -- stanzas/out filter can get called before this one and adds the xmlns. | 200 -- stanzas/out filter can get called before this one and adds the xmlns. |
| 201 if session.resending_unacked then return stanza end | |
| 201 local is_stanza = st.is_stanza(stanza) and | 202 local is_stanza = st.is_stanza(stanza) and |
| 202 (not stanza.attr.xmlns or stanza.attr.xmlns == 'jabber:client') | 203 (not stanza.attr.xmlns or stanza.attr.xmlns == 'jabber:client') |
| 203 and not stanza.name:find":"; | 204 and not stanza.name:find":"; |
| 204 | 205 |
| 205 if is_stanza and not stanza._cached then | 206 if is_stanza then |
| 206 local queue = session.outgoing_stanza_queue; | 207 local queue = session.outgoing_stanza_queue; |
| 207 local cached_stanza = st.clone(stanza); | 208 local cached_stanza = st.clone(stanza); |
| 208 cached_stanza._cached = true; | |
| 209 | 209 |
| 210 if cached_stanza.name ~= "iq" and cached_stanza:get_child("delay", xmlns_delay) == nil then | 210 if cached_stanza.name ~= "iq" and cached_stanza:get_child("delay", xmlns_delay) == nil then |
| 211 cached_stanza = cached_stanza:tag("delay", { | 211 cached_stanza = cached_stanza:tag("delay", { |
| 212 xmlns = xmlns_delay, | 212 xmlns = xmlns_delay, |
| 213 from = jid.bare(session.full_jid or session.host), | 213 from = jid.bare(session.full_jid or session.host), |
| 603 -- ...they are what is now left in the outgoing stanza queue | 603 -- ...they are what is now left in the outgoing stanza queue |
| 604 -- We have to use the send of "session" because we don't want to add our resent stanzas | 604 -- We have to use the send of "session" because we don't want to add our resent stanzas |
| 605 -- to the outgoing queue again | 605 -- to the outgoing queue again |
| 606 local queue = original_session.outgoing_stanza_queue; | 606 local queue = original_session.outgoing_stanza_queue; |
| 607 session.log("debug", "resending all unacked stanzas that are still queued after resume, #queue = %d", #queue); | 607 session.log("debug", "resending all unacked stanzas that are still queued after resume, #queue = %d", #queue); |
| 608 session.resending_unacked = true; | |
| 608 for i=1,#queue do | 609 for i=1,#queue do |
| 609 session.send(queue[i]); | 610 session.send(queue[i]); |
| 610 end | 611 end |
| 612 session.resending_unacked = nil; | |
| 611 session.log("debug", "all stanzas resent, now disabling send() in this migrated session, #queue = %d", #queue); | 613 session.log("debug", "all stanzas resent, now disabling send() in this migrated session, #queue = %d", #queue); |
| 612 function session.send(stanza) -- luacheck: ignore 432 | 614 function session.send(stanza) -- luacheck: ignore 432 |
| 613 migrated_session_log("error", "Tried to send stanza on old session migrated by smacks resume (maybe there is a bug?): %s", tostring(stanza)); | 615 migrated_session_log("error", "Tried to send stanza on old session migrated by smacks resume (maybe there is a bug?): %s", tostring(stanza)); |
| 614 return false; | 616 return false; |
| 615 end | 617 end |