-
-
Notifications
You must be signed in to change notification settings - Fork 335
fix: sync suppression list removal with AWS SES (closes #324) #331
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -2,6 +2,7 @@ import { SuppressionReason, SuppressionList } from "@prisma/client"; | |||||||||
| import { db } from "../db"; | ||||||||||
| import { UnsendApiError } from "~/server/public-api/api-error"; | ||||||||||
| import { logger } from "../logger/log"; | ||||||||||
| import { deleteFromSesSuppressionList } from "../aws/ses"; | ||||||||||
|
|
||||||||||
| export type AddSuppressionParams = { | ||||||||||
| email: string; | ||||||||||
|
|
@@ -120,22 +121,66 @@ export class SuppressionService { | |||||||||
| } | ||||||||||
|
|
||||||||||
| /** | ||||||||||
| * Remove email from suppression list | ||||||||||
| * Remove email from suppression list (both local DB and AWS SES) | ||||||||||
| */ | ||||||||||
| static async removeSuppression(email: string, teamId: number): Promise<void> { | ||||||||||
| const normalizedEmail = email.toLowerCase().trim(); | ||||||||||
|
|
||||||||||
| // Get all unique regions from team's domains for AWS SES cleanup | ||||||||||
| try { | ||||||||||
| const teamDomains = await db.domain.findMany({ | ||||||||||
| where: { teamId }, | ||||||||||
| select: { region: true }, | ||||||||||
| }); | ||||||||||
| const uniqueRegions = [...new Set(teamDomains.map((d) => d.region))]; | ||||||||||
|
|
||||||||||
| // Attempt to remove from AWS SES in all regions (best effort, don't throw) | ||||||||||
| if (uniqueRegions.length > 0) { | ||||||||||
| const results = await Promise.allSettled( | ||||||||||
| uniqueRegions.map((region) => | ||||||||||
| deleteFromSesSuppressionList(normalizedEmail, region) | ||||||||||
| ) | ||||||||||
| ); | ||||||||||
|
|
||||||||||
| const failures = results.filter((r) => r.status === "rejected"); | ||||||||||
|
||||||||||
| const failures = results.filter((r) => r.status === "rejected"); | |
| const failures = results.filter( | |
| (r) => r.status === "rejected" || (r.status === "fulfilled" && r.value === false) | |
| ); |
✅ Addressed in c63400f
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
P2: Logging only
error.messageloses the stack trace and other error details. The existing pattern in this file logs the full error object as{ err: error }for better debugging.Prompt for AI agents