Comparison

mod_push2/mod_push2.lua @ 6219:06621ab30be0

mod_push2: Improve session activity tracking
author Stephen Paul Weber <singpolyma@singpolyma.net>
date Tue, 25 Mar 2025 20:54:09 -0500
parent 6218:277db84b0c95
child 6233:1c16bb49f6f6
comparison
equal deleted inserted replaced
6218:277db84b0c95 6219:06621ab30be0
629 end 629 end
630 end 630 end
631 631
632 handle_notify_request(stanza, to_user, notify_push_services, event.origin, true); 632 handle_notify_request(stanza, to_user, notify_push_services, event.origin, true);
633 end 633 end
634
635 -- This is a message the user has sent, indicates activity on a session
636 if event.for_user == jid.node(stanza.attr.from) and module.host == jid.host(stanza.attr.from) then
637 event.origin.last_activity = os_time()
638 end
639 end 634 end
640 635
641 module:hook("smacks-hibernation-start", hibernate_session); 636 module:hook("smacks-hibernation-start", hibernate_session);
642 module:hook("smacks-hibernation-end", restore_session); 637 module:hook("smacks-hibernation-end", restore_session);
643 module:hook("smacks-ack-delayed", ack_delayed); 638 module:hook("smacks-ack-delayed", ack_delayed);
644 module:hook("smacks-hibernation-stanza-queued", process_smacks_stanza); 639 module:hook("smacks-hibernation-stanza-queued", process_smacks_stanza);
645 module:hook("archive-message-added", archive_message_added); 640 module:hook("archive-message-added", archive_message_added);
641
642 local function track_activity(event)
643 if has_body(event.stanza) or event.stanza:child_with_ns("http://jabber.org/protocol/chatstates") then
644 event.origin.last_activity = os_time()
645 end
646 end
647
648 module:hook("pre-message/bare", track_activity)
649 module:hook("pre-message/full", track_activity)
646 650
647 module:log("info", "Module loaded"); 651 module:log("info", "Module loaded");
648 function module.unload() 652 function module.unload()
649 module:log("info", "Unloading module"); 653 module:log("info", "Unloading module");
650 -- cleanup some settings, reloading this module can cause process_smacks_stanza() to stop working otherwise 654 -- cleanup some settings, reloading this module can cause process_smacks_stanza() to stop working otherwise