# HG changeset patch # User Stephen Paul Weber # Date 1738771455 18000 # Node ID aa240145aa22d1bd68242af5f5233e462e264a8c # Parent 72b7e0ca71ab5adf59063108eeb7b347ad93ea89 mod_push2: support for disabling push notifications For example when logging out diff -r 72b7e0ca71ab -r aa240145aa22 mod_push2/mod_push2.lua --- a/mod_push2/mod_push2.lua Tue Feb 04 23:40:33 2025 +0100 +++ b/mod_push2/mod_push2.lua Wed Feb 05 11:04:15 2025 -0500 @@ -106,6 +106,28 @@ end module:hook("iq-set/self/"..xmlns_push..":enable", push_enable) +local function push_disable(event) + local origin, stanza = event.origin, event.stanza; + local enable = stanza.tags[1]; + origin.log("debug", "Attempting to disable push notifications") + -- Tie registration to client, via client_id with sasl2 or else fallback to resource + local registration_id = origin.client_id or origin.resource + -- TODO: can we move to keyval+ on trunk? + local registrations = push2_registrations:get(origin.username) or {} + registrations[registration_id] = nil + if not push2_registrations:set(origin.username, registrations) then + origin.send(st.error_reply(stanza, "wait", "internal-server-error")); + else + origin.push_registration_id = nil + origin.push_registration = nil + origin.first_hibernated_push = nil + origin.log("info", "Push notifications disabled for %s (%s)", tostring(stanza.attr.from), registration_id) + origin.send(st.reply(stanza)) + end + return true +end +module:hook("iq-set/self/"..xmlns_push..":disable", push_disable) + -- urgent stanzas should be delivered without delay local function is_voip(stanza) if stanza.name == "message" then diff -r 72b7e0ca71ab -r aa240145aa22 mod_push2/push2.md --- a/mod_push2/push2.md Tue Feb 04 23:40:33 2025 +0100 +++ b/mod_push2/push2.md Wed Feb 05 11:04:15 2025 -0500 @@ -129,6 +129,12 @@ ``` +## Client disables future pushes + +```xml + +``` + ## Push service interactions ### Transient delivery errors