Repository navigation
feat(email): notify active monthly plan donors when receiving account is replaced (Refs #291) - #307
Conversation
There was a problem hiding this comment.
If your organization's extra usage balance is empty, an organization admin can add extra usage credits at claude.ai/admin-settings/usage. If its monthly spend limit was reached, an admin can raise it on the same page. If neither applies, contact Anthropic support.
Once extra usage is available, someone with write access to this repository can comment @claude review on this pull request to trigger a review.
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the
|
|
PO acceptance: merge at 7481687 Verified on GitHub:
|
Summary
Phase 2 app template and admin outbox labels for
plan_account_swapped(follows Phase 1 DB migration DOS/DOS.Me#187120261130130000_give_plan_account_swap_notice.sql, merged and verified on Beta at4dd78004d).apps/web/src/server/email/templates.ts):plan_account_swappedtoEMAIL_KINDSandSTOP_LINK_KINDSso every outgoing swap notice carries both a signed one-click plan stop link (/plans/stop?t=...& RFC 8058List-Unsubscribe: </api/plans/stop?t=...>) and a notification unsubscribe link (/email/unsubscribe?t=...), refusing to send if either token is missing or malformed.DD/MM/YYYY, Vietnam time), the new account holder name, bank short name (or crypto chain), and masked last 4 digits only (•••• XXXX), with strict regex validation (maskedLast4) so raw account numbers can never render even from a malformed payload./campaigns/<slug>.Không muốn nhận các email thông báo như thế này?) instead ofemail tổng kếtfor non-summary notifications.apps/web/src/lib/email-outbox.ts):OUTBOX_KIND_LABELS.plan_account_swapped,OUTBOX_SKIP_LABELS.plan_not_active,OUTBOX_SKIP_LABELS.account_superseded, and mirrorsgive.outbox_max_age('plan_account_swapped')(14days) inoutboxMaxAgeDays.email-outbox.test.ts,templates.test.ts,outbox.test.ts):changed_dateis absent, defense-in-depth anti-leak of raw account numbers, HTML escaping, missing stop/unsubscribe token rejection,sendDueEmailsheader/body wiring, and admin kind/skip/max-age parity.Verification
pnpm test: 180/180 files, 2629/2629 tests passed.pnpm lint,pnpm typecheck,pnpm format:check,pnpm build: all passed.Refs #291
📌 TL;DR
Introduces a new
plan_account_swappedemail notification to inform monthly donors when a campaign's receiving bank or crypto account changes. The implementation includes strict input validation to prevent PII leakage (e.g., full account numbers), supports both bank and crypto channels, and integrates the email into the existing outbox lifecycle with appropriate retention and unsubscribe logic.🎯 Type of Change
🔍 Changes Walkthrough
apps/web/src/lib/email-outbox.tsplan_account_swappedto the outbox kind labels, skip labels, and max-age configuration (14 days).apps/web/src/lib/email-outbox.test.tsapps/web/src/server/email/templates.tsplanAccountSwappedemail template. Adds strict regex validation for account last-4 digits and crypto chains to prevent PII leakage. Integrates the new kind into theEMAIL_KINDSlist andSTOP_LINK_KINDS. Refactors the unsubscribe prompt text to be generic for non-campaign-ended emails.apps/web/src/server/email/templates.test.tsapps/web/src/server/email/outbox.test.tsplan_account_swappedemails include signed stop tokens and unsubscribe headers, and are marked as "dead" if required tokens are missing.📊 Architectural Flow
sequenceDiagram participant Outbox as Email Outbox participant Sender as sendDueEmails participant Renderer as renderEmail participant Validator as maskedLast4/swapDateLabel participant Transport as Email Transport Outbox->>Sender: Claim due email (kind: plan_account_swapped) Sender->>Renderer: renderEmail(email, origin, {signedStopToken}) Renderer->>Validator: Validate payload (last4, chain, dates) alt Invalid PII or Missing Tokens Validator-->>Renderer: Throw EmailRenderError Renderer-->>Sender: Error (stop_token_missing / unsubscribe_token_missing) Sender->>Outbox: Mark as dead (permanent error) else Valid Payload Validator-->>Renderer: Sanitized strings (•••• 0002) Renderer->>Renderer: Build HTML/Text content Renderer-->>Sender: Content + Unsubscribe/Stop URLs Sender->>Transport: Send email with List-Unsubscribe headers Transport-->>Sender: Success Sender->>Outbox: Mark as sent end