aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthew Wild <mwild1@gmail.com>2011-03-29 14:10:00 +0100
committerMatthew Wild <mwild1@gmail.com>2011-03-29 14:10:00 +0100
commit4e83c7ddd66031d6a67d7c8cfda36f7b514ac1b6 (patch)
treec5e263ee6aac54bc9e26d70bb224b8748f3ba44a
parent1f049ed80d3a07636a207b859cc236e3d39eb4f1 (diff)
downloadprosody-4e83c7ddd66031d6a67d7c8cfda36f7b514ac1b6.tar.gz
prosody-4e83c7ddd66031d6a67d7c8cfda36f7b514ac1b6.zip
sessionmanager: Fire pre-resource-unbind to allow plugins (such as mod_smacks) to hook and prevent/override session destruction
-rw-r--r--core/sessionmanager.lua15
1 files changed, 11 insertions, 4 deletions
diff --git a/core/sessionmanager.lua b/core/sessionmanager.lua
index d36591bf..426763f5 100644
--- a/core/sessionmanager.lua
+++ b/core/sessionmanager.lua
@@ -108,16 +108,23 @@ function destroy_session(session, err)
-- Remove session/resource from user's session list
if session.full_jid then
- hosts[session.host].sessions[session.username].sessions[session.resource] = nil;
+ local host_session = hosts[session.host];
+
+ -- Allow plugins to prevent session destruction
+ if host_session.events.fire_event("pre-resource-unbind", {session=session, error=err}) then
+ return;
+ end
+
+ host_session.sessions[session.username].sessions[session.resource] = nil;
full_sessions[session.full_jid] = nil;
- if not next(hosts[session.host].sessions[session.username].sessions) then
+ if not next(host_session.sessions[session.username].sessions) then
log("debug", "All resources of %s are now offline", session.username);
- hosts[session.host].sessions[session.username] = nil;
+ host_session.sessions[session.username] = nil;
bare_sessions[session.username..'@'..session.host] = nil;
end
- hosts[session.host].events.fire_event("resource-unbind", {session=session, error=err});
+ host_session.events.fire_event("resource-unbind", {session=session, error=err});
end
retire_session(session);