# HG changeset patch # User Stephen Paul Weber # Date 1742954049 18000 # Node ID 06621ab30be082376d1fb4a1540504b4f6f887dc # Parent 277db84b0c95e883f0729d5cc2c83749a222f092 mod_push2: Improve session activity tracking diff -r 277db84b0c95 -r 06621ab30be0 mod_push2/mod_push2.lua --- a/mod_push2/mod_push2.lua Tue Mar 25 20:43:51 2025 -0500 +++ b/mod_push2/mod_push2.lua Tue Mar 25 20:54:09 2025 -0500 @@ -631,11 +631,6 @@ handle_notify_request(stanza, to_user, notify_push_services, event.origin, true); end - - -- This is a message the user has sent, indicates activity on a session - if event.for_user == jid.node(stanza.attr.from) and module.host == jid.host(stanza.attr.from) then - event.origin.last_activity = os_time() - end end module:hook("smacks-hibernation-start", hibernate_session); @@ -644,6 +639,15 @@ module:hook("smacks-hibernation-stanza-queued", process_smacks_stanza); module:hook("archive-message-added", archive_message_added); +local function track_activity(event) + if has_body(event.stanza) or event.stanza:child_with_ns("http://jabber.org/protocol/chatstates") then + event.origin.last_activity = os_time() + end +end + +module:hook("pre-message/bare", track_activity) +module:hook("pre-message/full", track_activity) + module:log("info", "Module loaded"); function module.unload() module:log("info", "Unloading module");