fix: re-check subscription before SES submission - #462
Open
vladbisceanu wants to merge 2 commits into
Open
Conversation
…cribe-recheck # Conflicts: # apps/api/src/jobs/email-processor.ts
Author
|
Updated the branch to current Verification on the merged tree:
GitHub now reports the PR mergeable and waiting only for review. |
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.
Queued marketing emails can outlive the subscription state checked when they were created. A contact who unsubscribes while an email waits in Redis can therefore still receive it.
This change re-reads the contact immediately before the SES call and suppresses the email when the latest state is unsubscribed. It preserves Plunk’s existing exemptions for transactional sends, headless transactional templates, and explicit recipient overrides. Marketing templates sent through the transactional endpoint remain subject to opt-out.
Verification:
yarn test:run apps/api/src/jobs/__tests__/email-processor.test.ts --maxWorkers=1(15 tests)yarn build --filter=apiThe final review noted the unavoidable gap between the database read and an external SES request. Holding a database lock across a network call would delay the unsubscribe transaction rather than make the two systems atomic, so this keeps the check at the last practical boundary before submission.