You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
API announcements are Brevo campaigns, so their unsubscribe link is Brevo's own and doesn't carry our subscription ID. After someone unsubscribes, Brevo redirects them to /notifications/unsubscribe with no id, which showed an error. The API's daily reconcile can also take up to 24 hours to turn the subscription off. Until then the account page still showed "subscribed", and saving the form with that value would re-subscribe the user.
/notifications/unsubscribe with no id: shows a confirmation ("you've been unsubscribed… up to 24 hours to show on your account") instead of an error. The main button goes to /account?sync=announcements, through sign-in when signed out. A malformed id still shows the error.
/account?sync=announcements: calls the new POST /v1/user/announcements/sync before showing the announcements checkbox. Edit is disabled while it runs. Afterwards the opt-in is updated in Redux and sync is removed from the URL. If the call fails, a note says the change can take up to 24 hours.
Supporting changes: a setApiAnnouncementsOptIn reducer action (updates only the flag), syncAnnouncementsFromBrevo() in profile-service.ts, the user-service spec and types regenerated, and English and French text.
Depends on MobilityData/mobility-feed-api#.
Expected behavior:
/notifications/unsubscribe with no id shows the confirmation and a "Sign in to manage subscriptions" button; signed-in visitors see "Manage notifications" instead.
After sign-in, /account briefly hides the announcements checkbox. It then shows unchecked if the user unsubscribed in Brevo, and the URL becomes /account.
Links with an id behave as before.
Testing tips:
No-id page: open /notifications/unsubscribe while signed out, click "Sign in to manage subscriptions" and sign in. You should land on /account with the checkbox reflecting Brevo.
Unsubscribed user: unsubscribe a test contact in Brevo (dev), then open /account?sync=announcements as that user. The checkbox should be unchecked even before the nightly reconcile runs.
Failure: with the API endpoint unavailable, /account?sync=announcements should show the "up to 24 hours" note and keep the stored value.
After deploy: set Brevo's post-unsubscribe redirect to https://mobilitydatabase.org/notifications/unsubscribe.
Run the unit tests with yarn test to make sure you didn't break anything
Add or update any needed documentation to the repo
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
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.
Summary:
API announcements are Brevo campaigns, so their unsubscribe link is Brevo's own and doesn't carry our subscription ID. After someone unsubscribes, Brevo redirects them to
/notifications/unsubscribewith noid, which showed an error. The API's daily reconcile can also take up to 24 hours to turn the subscription off. Until then the account page still showed "subscribed", and saving the form with that value would re-subscribe the user./notifications/unsubscribewith noid: shows a confirmation ("you've been unsubscribed… up to 24 hours to show on your account") instead of an error. The main button goes to/account?sync=announcements, through sign-in when signed out. A malformedidstill shows the error./account?sync=announcements: calls the newPOST /v1/user/announcements/syncbefore showing the announcements checkbox. Edit is disabled while it runs. Afterwards the opt-in is updated in Redux andsyncis removed from the URL. If the call fails, a note says the change can take up to 24 hours.setApiAnnouncementsOptInreducer action (updates only the flag),syncAnnouncementsFromBrevo()inprofile-service.ts, the user-service spec and types regenerated, and English and French text.Depends on MobilityData/mobility-feed-api#.
Expected behavior:
/notifications/unsubscribewith noidshows the confirmation and a "Sign in to manage subscriptions" button; signed-in visitors see "Manage notifications" instead./accountbriefly hides the announcements checkbox. It then shows unchecked if the user unsubscribed in Brevo, and the URL becomes/account.idbehave as before.Testing tips:
No-
idpage: open/notifications/unsubscribewhile signed out, click "Sign in to manage subscriptions" and sign in. You should land on/accountwith the checkbox reflecting Brevo.Unsubscribed user: unsubscribe a test contact in Brevo (dev), then open
/account?sync=announcementsas that user. The checkbox should be unchecked even before the nightly reconcile runs.Failure: with the API endpoint unavailable,
/account?sync=announcementsshould show the "up to 24 hours" note and keep the stored value.After deploy: set Brevo's post-unsubscribe redirect to
https://mobilitydatabase.org/notifications/unsubscribe.Run the unit tests with
yarn testto make sure you didn't break anythingAdd or update any needed documentation to the repo
Format the title like "feat: [new feature short description]". Title must follow the Conventional Commit Specification(https://www.conventionalcommits.org/en/v1.0.0/).
Linked all relevant issues
Include screenshot(s) showing how this pull request works and fixes the issue(s)