Skip to content

fix: handle Brevo unsubscribe redirect and refresh announcements opt-in - #267

Merged
davidgamez merged 2 commits into
mainfrom
fix/brevo-remove-subscription-id
Nov 18, 2026
Merged

davidgamez merged 2 commits into
mainfrom
fix/brevo-remove-subscription-id

Conversation

@davidgamez

Copy link
Copy Markdown
Member

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/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

  • 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)

@vercel

vercel Bot commented Nov 17, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
mobilitydatabase-web Ready Ready Preview Nov 18, 2026 1:44pm UTC

Request Review

@davidgamez

Copy link
Copy Markdown
Member Author

Landing page after Brevo confirmation:
Screenshot 2026-11-17 at 11 32 19 AM

@github-actions

Copy link
Copy Markdown

*Lighthouse ran on https://mobilitydatabase-d42tnthr6-mobility-data.vercel.app/ * (Desktop)
⚡️ HTML Report Lighthouse report for the changes in this PR:

Performance Accessibility Best Practices SEO
🟠 62 🟢 90 🟢 96 🟢 100

*Lighthouse ran on https://mobilitydatabase-d42tnthr6-mobility-data.vercel.app/feeds * (Desktop)
⚡️ HTML Report Lighthouse report for the changes in this PR:

Performance Accessibility Best Practices SEO
🟠 86 🟠 87 🟢 96 🟢 100

*Lighthouse ran on https://mobilitydatabase-d42tnthr6-mobility-data.vercel.app/feeds/gtfs/mdb-2126 * (Desktop)
⚡️ HTML Report Lighthouse report for the changes in this PR:

Performance Accessibility Best Practices SEO
🔴 37 🟢 95 🟢 96 🟢 100

*Lighthouse ran on https://mobilitydatabase-d42tnthr6-mobility-data.vercel.app/feeds/gtfs_rt/mdb-2585 * (Desktop)
⚡️ HTML Report Lighthouse report for the changes in this PR:

Performance Accessibility Best Practices SEO
🟢 97 🟠 84 🟢 96 🟢 100

*Lighthouse ran on https://mobilitydatabase-d42tnthr6-mobility-data.vercel.app/feeds/gbfs/gbfs-flamingo_porirua * (Desktop)
⚡️ HTML Report Lighthouse report for the changes in this PR:

Performance Accessibility Best Practices SEO
🟢 90 🟢 94 🟢 96 🟢 100

@Alessandro100 Alessandro100 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

@davidgamez
davidgamez merged commit dfe4f92 into main Nov 18, 2026
5 checks passed

This branch was successfully deployed

1 active deployment
Preview — 93149b72 Deployed Nov 18, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants