diff options
-rw-r--r-- | core/sessionmanager.lua | 8 | ||||
-rw-r--r-- | plugins/mod_presence.lua | 11 |
2 files changed, 11 insertions, 8 deletions
diff --git a/core/sessionmanager.lua b/core/sessionmanager.lua index 91a8a22f..5d7c1c39 100644 --- a/core/sessionmanager.lua +++ b/core/sessionmanager.lua @@ -56,14 +56,6 @@ end function destroy_session(session, err) (session.log or log)("info", "Destroying session for %s (%s@%s)", session.full_jid or "(unknown)", session.username or "(unknown)", session.host or "(unknown)"); - -- Send unavailable presence - if session.presence then - local pres = st.presence{ type = "unavailable" }; - if (not err) or err == "closed" then err = "connection closed"; end - pres:tag("status"):text("Disconnected: "..err):up(); - session:dispatch_stanza(pres); - end - -- Remove session/resource from user's session list if session.full_jid then hosts[session.host].events.fire_event("resource-unbind", {session=session, error=err}); diff --git a/plugins/mod_presence.lua b/plugins/mod_presence.lua index 9ae068c2..4fa9f431 100644 --- a/plugins/mod_presence.lua +++ b/plugins/mod_presence.lua @@ -315,3 +315,14 @@ module:hook("presence/full", function(data) end -- resource not online, discard
return true;
end);
+
+module:hook("resource-unbind", function(event)
+ local session, err = event.session, event.error;
+ -- Send unavailable presence
+ if session.presence then
+ local pres = st.presence{ type = "unavailable" };
+ if not(err) or err == "closed" then err = "connection closed"; end
+ pres:tag("status"):text("Disconnected: "..err):up();
+ session:dispatch_stanza(pres);
+ end
+end);
|