Software / code / prosody-modules
Comparison
mod_push2/mod_push2.lua @ 6214:fe9f2c618e8a
mod_push2: option to keep hibernating after first push
| author | Stephen Paul Weber <singpolyma@singpolyma.net> |
|---|---|
| date | Mon, 24 Mar 2025 09:28:25 -0500 |
| parent | 6213:811bd0872682 |
| child | 6215:e53f0967520c |
comparison
equal
deleted
inserted
replaced
| 6213:811bd0872682 | 6214:fe9f2c618e8a |
|---|---|
| 14 local xmlns_push = "urn:xmpp:push2:0"; | 14 local xmlns_push = "urn:xmpp:push2:0"; |
| 15 | 15 |
| 16 -- configuration | 16 -- configuration |
| 17 local contact_uri = module:get_option_string("contact_uri", "xmpp:" .. module.host) | 17 local contact_uri = module:get_option_string("contact_uri", "xmpp:" .. module.host) |
| 18 local extended_hibernation_timeout = module:get_option_number("push_max_hibernation_timeout", 72*3600) -- use same timeout like ejabberd | 18 local extended_hibernation_timeout = module:get_option_number("push_max_hibernation_timeout", 72*3600) -- use same timeout like ejabberd |
| 19 local hibernate_past_first_push = module:get_option_boolean("hibernate_past_first_push", true) | |
| 19 | 20 |
| 20 local host_sessions = prosody.hosts[module.host].sessions | 21 local host_sessions = prosody.hosts[module.host].sessions |
| 21 local push2_registrations = module:open_store("push2_registrations", "keyval") | 22 local push2_registrations = module:open_store("push2_registrations", "keyval") |
| 22 | 23 |
| 23 if _VERSION:match("5%.1") or _VERSION:match("5%.2") then | 24 if _VERSION:match("5%.1") or _VERSION:match("5%.2") then |
| 427 if handle_notify_request(stanza, node, user_push_services, session, false) ~= 0 then | 428 if handle_notify_request(stanza, node, user_push_services, session, false) ~= 0 then |
| 428 if session.hibernating and not session.first_hibernated_push then | 429 if session.hibernating and not session.first_hibernated_push then |
| 429 -- if the message was important | 430 -- if the message was important |
| 430 -- then record the time of first push in the session for the smack module which will extend its hibernation | 431 -- then record the time of first push in the session for the smack module which will extend its hibernation |
| 431 -- timeout based on the value of session.first_hibernated_push | 432 -- timeout based on the value of session.first_hibernated_push |
| 432 if is_important(stanza, session) then | 433 if is_important(stanza, session) and not hibernate_past_first_push then |
| 433 session.first_hibernated_push = os_time(); | 434 session.first_hibernated_push = os_time(); |
| 434 -- check for prosody 0.12 mod_smacks | 435 -- check for prosody 0.12 mod_smacks |
| 435 if session.hibernating_watchdog and session.original_smacks_callback and session.original_smacks_timeout then | 436 if session.hibernating_watchdog and session.original_smacks_callback and session.original_smacks_timeout then |
| 436 -- restore old smacks watchdog (--> the start of our original timeout will be delayed until first push) | 437 -- restore old smacks watchdog (--> the start of our original timeout will be delayed until first push) |
| 437 session.hibernating_watchdog:cancel(); | 438 session.hibernating_watchdog:cancel(); |