feat: web push notifications for custom domains#3001
Open
Soxasora wants to merge 3 commits into
Open
Conversation
…l, api routes are not touched by the proxy middleware
… for notifications
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Push notifications on custom domains work out of the box, but they have a couple of issues:
stacker.newsbecause of the hardcodednotification.navigateURLThis PR handles (2) and (3), the first issue is instead something we need to explore in-depth.
Screenshots
Branded push subscription:
Navigation to custom domain:
push-navigation.mp4
Additional Context
Checklist
Are your changes backward compatible? Please answer below:
Yes,
PushSubscriptiontable now has thedomainIdforeign key to carry the domain context across web push.On a scale of 1-10 how well and how have you QA'd this change and any features it might affect? Please answer below:
6, push notifications for custom domains work great, and SN push notifications work as expected. Didn't test navigation on mobile devices.
Did you use AI for this? If so, how much did it assist you?
Yes, review
Note
Medium Risk
Changes user-visible push behavior (URLs and branding) for all subscriptions; schema migration is backward compatible but per-subscription payload logic is new surface area for regressions on main SN and custom domains.
Overview
Push subscriptions now record which host the user subscribed from via optional
domainIdonPushSubscription, resolved at save time through a new lazygetDomain()on GraphQL context (fromreq.headers.host).Sending builds notification payloads per subscription: custom-domain favicon/title, absolute
navigateURLs on the territory’s domain (not hardcodedNEXT_PUBLIC_URL), and a branded “notifications are now active” reply.getDomainMappingByIdsupports lookup when onlydomainIdis stored.Existing rows keep
domainIdnull and behave like main Stacker News. Duplicate notifications across SN and a custom-domain PWA are not addressed here.Reviewed by Cursor Bugbot for commit 6121d55. Bugbot is set up for automated code reviews on this repo. Configure here.