aboutsummaryrefslogtreecommitdiffstats
path: root/plugins/mod_smacks.lua
diff options
context:
space:
mode:
authorKim Alvefur <zash@zash.se>2021-12-16 22:59:51 +0100
committerKim Alvefur <zash@zash.se>2021-12-16 22:59:51 +0100
commit6745972708034e703560ed6b05a63d1371c93977 (patch)
tree6f00ce49b9bd89e978062c500bf645e71f130871 /plugins/mod_smacks.lua
parentd87188b309934c4afc1c478f63cf6d309d511651 (diff)
downloadprosody-6745972708034e703560ed6b05a63d1371c93977.tar.gz
prosody-6745972708034e703560ed6b05a63d1371c93977.zip
mod_smacks: Skip hibernation logic if session was closed or replaced
The resumption_token is removed when the session is closed via the pre-session-close event, signaling that it cannot be resumed, and therefore no hibernation timeout logic should be invoked. Fixes that if a session somehow is replaced by a new one using the same resource (which is the common behavior), the old session would still be around until it times out at which point it sends `<presence type="unavailable"/>` which would look as if it came from the new session, ie appearing offline to everyone including MUCs.
Diffstat (limited to 'plugins/mod_smacks.lua')
-rw-r--r--plugins/mod_smacks.lua4
1 files changed, 4 insertions, 0 deletions
diff --git a/plugins/mod_smacks.lua b/plugins/mod_smacks.lua
index 7a0b608b..2dc8f1ff 100644
--- a/plugins/mod_smacks.lua
+++ b/plugins/mod_smacks.lua
@@ -436,6 +436,10 @@ module:hook("pre-resource-unbind", function (event)
if session.destroyed then
session.log("debug", "The session has already been destroyed");
return
+ elseif not session.resumption_token then
+ -- This should normally not happen, the watchdog should be canceled from session:close()
+ session.log("debug", "The session has already been resumed or replaced");
+ return
end
session.log("debug", "Destroying session for hibernating too long");