The discussion addresses a critical issue where logging out of a Discourse forum deletes all push subscriptions, preventing notifications from reaching other active devices. MojoK highlights that while subscriptions are recreated upon login, a logout from one session invalidates subscriptions globally. Falco initially suspected this behavior might be limited to specific code paths but confirmed it occurs universally upon logout.
To resolve this, MojoK proposes utilizing the browser’s Push API unsubscribe function on the client side. This approach would invalidate only the specific subscription for the device logging out, preserving others, rather than deleting all server-side records. The suggested fix involves two steps: removing the existing server-side cleanup code and implementing client-side unsubscription logic during logout.
Falco agrees with this two-part solution, noting that the server currently lacks tracking for specific device subscriptions. The proposed changes were successfully implemented and merged in pull request #39266.
Also it seems like when a user logouts, all push subscriptions are deleted. So if a user is logged in on multiple devices (phone, browser, tablet) and logouts from one device/session, it prevents other devices from getting notifications as their push subscriptions are deleted.
I mention this as its related to knowing which subscription needs to be replaced during renewal, and which subscription should be deleted on logout.
Well I was just logged out of Meta today and after logging in I got a push notification for your post… Unless it’s only on the user initiated login code path
When a user comes back to the forum (or logs in), the browsers push subscriptions are sent again and are recreated. But if you logged out, they are deleted and no push notifications will be delivered until that user goes to the forum from that device.
This doesn’t contradict what you stated since you appear to be saying you got the push notification after logging in.
The Push API does have a unsubscribe function to invalidate the push subscription:
On logout, we would invoke this (client side) would render that subscription on the server as invalid without affecting any other subscriptions.
In fact, the client already has a unsubscribePushNotification function that does this in the “Live Notification” prefrences. Maybe the solution is to invoke this on logout client side if Live Notifications is enabled. Probably good practice to revoke the client side subscription keys instead of just deleting them from server.