Skip to content

Add GC Notify one-click unsubscribe callback endpoint#124

Open
smcmurtry wants to merge 3 commits intoServiceCanada:masterfrom
smcmurtry:feat/unsubscribe
Open

Add GC Notify one-click unsubscribe callback endpoint#124
smcmurtry wants to merge 3 commits intoServiceCanada:masterfrom
smcmurtry:feat/unsubscribe

Conversation

@smcmurtry
Copy link
Copy Markdown

@smcmurtry smcmurtry commented Apr 27, 2026

Adds POST /api/v1/notify/unsubscribe to receive RFC 8058 unsubscribe webhooks from GC Notify. When a recipient clicks the unsubscribe button in Gmail (or another RFC 8058 client), this endpoint receives a POST request the recipient's email address and the template ID.

The handler:

  • Looks up the CENS topic by templateId
  • Removes the subscriber using the same logic as /subs/remove/:subscode: findOneAndDelete from subsConfirmed, insert into subsUnsubs, findOneAndDelete from subsExist, upsert into subsRecents
  • Returns 200 OK with skipped:true if the template or subscriber is not found

CENS's own /subs/remove/:subscode body link is unchanged. This is a secondary path triggered only by email-client header-level unsubscribes.

You can test by sending a curl request like this, mimicking what Gmail would send (replace $SUBSCODE with a valid code):

curl -v -X POST "http://localhost:8080/subs/remove/$SUBSCODE" \
  -H 'Content-Type: application/x-www-form-urlencoded' \
  -d 'List-Unsubscribe=One-Click'

Adds POST /api/v1/notify/unsubscribe to receive RFC 8058 unsubscribe
webhooks from GC Notify. When a recipient clicks the unsubscribe button
in Gmail (or another RFC 8058 client), Notify POSTs to this endpoint
with the email address and template ID.

The handler:
- Authenticates via Bearer token (NOTIFY_UNSUBSCRIBE_BEARER_TOKEN env var)
- Looks up the CENS topic by templateId
- Removes the subscriber using the same logic as /subs/remove/:subscode:
  findOneAndDelete from subsConfirmed, insert into subsUnsubs,
  findOneAndDelete from subsExist, upsert into subsRecents
- Returns 200 OK with skipped:true if the template or subscriber is not
  found (avoids Notify retry loops)

CENS's own /subs/remove/:subscode body link is unchanged. This is a
secondary path triggered only by email-client header-level unsubscribes.
@smcmurtry smcmurtry requested a review from a team April 27, 2026 14:57
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.

1 participant