Skip to content

:hedgehog: PostHog is the leading platform for building self-driving products. Our developer tools – AI observability, analytics, session replay, flags, experiments, error tracking, logs, and more – capture all the context agents need to diagnose problems, uncover opportunities, and ship fixes. Steer it all from Slack, web, desktop, or the MCP.

fix(workflows): drop suppressed cc/bcc instead of skipping the email (#118456)

Harley Alexander51da20edc690
diff --git a/nodejs/src/cdp/services/messaging/email.service.test.ts b/nodejs/src/cdp/services/messaging/email.service.test.ts
index ff3b05045580..459f664a7da7 100644
--- a/nodejs/src/cdp/services/messaging/email.service.test.ts
+++ b/nodejs/src/cdp/services/messaging/email.service.test.ts
@@ -1111,6 +1111,31 @@ describe('EmailService', () => {
expect(result.metrics.map((m) => m.metric_name)).not.toContain('email_sent')
})
+ it('moves the first deliverable cc address to To when the To address is suppressed', async () => {
+ const suppressed = new Set(['[email protected]', '[email protected]', '[email protected]'])
+ jest.spyOn(service['emailSuppressionService'], 'isSuppressed').mockImplementation((_teamId, email) =>
+ Promise.resolve(suppressed.has(email))
+ )
+ sendEmailSpy.mockResolvedValue({ MessageId: 'test-message-id' })
+ invocation.queueParameters = createEmailParams({
+ from: { integrationId: 1 },
+ })
+
+ const result = await service.executeSendEmail(invocation)
+
+ const sentCommand = sendEmailSpy.mock.calls[0][0] as { input: any }
+ expect(sentCommand.input.Destination).toEqual({
+ ToAddresses: ['[email protected]'],
+ CcAddresses: ['[email protected]'],
+ })
+ expect(result.metrics.map((m) => m.metric_name)).toContain('email_sent')
+ expect(result.logs.map((l) => l.message).join(' ')).toContain(
+ )
+ })
+
it('calls SES when the recipient is not suppressed', async () => {
jest.spyOn(service['emailSuppressionService'], 'isSuppressed').mockResolvedValue(false)
sendEmailSpy.mockResolvedValue({ MessageId: 'test-message-id' })
diff --git a/nodejs/src/cdp/services/messaging/email.service.ts b/nodejs/src/cdp/services/messaging/email.service.ts
index a918740f840a..c0f4581a699c 100644
--- a/nodejs/src/cdp/services/messaging/email.service.ts
+++ b/nodejs/src/cdp/services/messaging/email.service.ts
@@ -30,6 +30,7 @@ import {
import { mailDevTransport, mailDevWebUrl } from './helpers/maildev'
import { maybeAddPreheaderToEmail } from './helpers/preheader'
import { SES_SENSITIVE_TAG } from './helpers/ses'
+import { quoteMailbox, removeSuppressedRecipients, unquoteMailbox } from './helpers/suppressed-recipients'
import { EmailTrackingCodeSigner, TRACKING_CODE_HEADER_NAME } from './helpers/tracking-code'
import { addUtmTagsToEmail, renderUtmOverrides, resolveUtmTags } from './helpers/utm'
import { MessageAssetsService } from './message-assets.service'
@@ -518,11 +519,16 @@ export class EmailService {
// Single choke point for the suppression check — every send path lands here regardless
// of whether the invocation came from a workflow action or an email destination hog
// function. Checking here means callers can't bypass it by taking a different upstream
- // route. Covers `to`, `cc`, and `bcc`; a suppressed address anywhere blocks the send.
- const skipReason = await this.buildSuppressionSkipReason(invocation.teamId, params, {
+ // route. Suppressed addresses are removed from every list. A suppressed `to` is replaced by
+ // the first deliverable cc address, and the send is skipped only when none is left.
+ const suppressionOptions: SuppressionCheckOptions = {
transactional: invocation.hogFunction?.metadata?.message_category_type === 'transactional',
- })
- if (skipReason) {
+ }
+ const suppression = await removeSuppressedRecipients(params, (email) =>
+ this.emailSuppressionService.isSuppressed(invocation.teamId, email, suppressionOptions)
+ )
+ if (suppression.skip) {
+ const skipReason = `Skipping send: ${suppression.removed.join(', ')} ${suppression.removed.length === 1 ? 'is' : 'are'} on the suppression list and no cc address can receive the email instead`
addLog('info', skipReason)
result.emailSendResult = { status: 'skipped', reason: skipReason }
if (!isTest) {
@@ -538,10 +544,30 @@ export class EmailService {
result.invocation.state.vmState?.stack.push({ success: false })
return result
}
+ if (suppression.removed.length > 0) {
+ const promoted = suppression.promotedTo
+ ? ` ${suppression.promotedTo.email} moves from cc to the To field.`
+ : ''
+ addLog(
+ 'warn',
+ `Not sending to ${suppression.removed.join(', ')} because ${suppression.removed.length === 1 ? 'it is' : 'they are'} on the suppression list.${promoted} The email still goes to the other recipients.`
+ )
+ }
+ // Always send the lists the suppression check parsed, so delivery uses the addresses it checked.
+ const deliverableParams = {
+ ...params,
+ to:
+ suppression.promotedTo ??
+ (params.to?.email
+ ? { ...params.to, email: quoteMailbox(unquoteMailbox(params.to.email)) }
+ : params.to),
+ cc: suppression.cc,
+ bcc: suppression.bcc,
+ }
// Like suppression, the tracking decision lives at this choke point so every send path
// (workflow action or email destination hog function) resolves it the same way.
- trackingEnabled = await this.resolveTrackingEnabled(result.invocation, params)
+ trackingEnabled = await this.resolveTrackingEnabled(result.invocation, deliverableParams)
// User-configured per-workflow pacing. Claimed last, after every skip gate, so a
// suspended or suppressed send never spends a token. Test sends bypass it. When the
@@ -591,7 +617,9 @@ export class EmailService {
// Charged per recipient, not per send: SES counts every to/cc/bcc address against its
// own quota, so a send with many copies must spend that many tokens.
const capRecipients =
- 1 + extractEmailsFromAddressList(params.cc).length + extractEmailsFromAddressList(params.bcc).length
+ 1 +
+ extractEmailsFromAddressList(deliverableParams.cc).length +
+ extractEmailsFromAddressList(deliverableParams.bcc).length
const capDelay = await this.claimTeamSendingBudget(invocation, isTest, capRecipients)
if (capDelay) {
result.finished = false
@@ -612,9 +640,9 @@ export class EmailService {
// A reply-to set on the email step wins over the sender's default.
const paramsWithReplyTo =
- parseAddressList(params.replyTo) || !integration.config.reply_to
- ? params
- : { ...params, replyTo: integration.config.reply_to }
+ parseAddressList(deliverableParams.replyTo) || !integration.config.reply_to
+ ? deliverableParams
+ : { ...deliverableParams, replyTo: integration.config.reply_to }
// Tagged before click tracking wraps the links, so the tags land on the destination URL.
const metadata = invocation.hogFunction.metadata
@@ -663,7 +691,7 @@ export class EmailService {
assetRow = this.messageAssetsService.buildRowForEmail(invocation, sendParams)
}
const viewEmailToken = assetRow ? ` [Email:${invocation.id}:${invocation.state.actionId ?? ''}]` : ''
- addLog('info', `Email sent to ${params.to.email} from ${from.name} <${from.email}>${viewEmailToken}`)
+ addLog('info', `Email sent to ${sendParams.to.email} from ${from.name} <${from.email}>${viewEmailToken}`)
success = true
result.emailSendResult = { status: 'accepted' }
} catch (error) {
@@ -865,39 +893,6 @@ export class EmailService {
return null
}
- // Returns a human-readable log string when any destination address is suppressed for the team,
- // or null when the send should proceed. Scans to + cc + bcc — SES delivers to every list, so a
- // suppressed address anywhere blocks the whole send. `cc` and `bcc` can be comma-separated
- // lists with RFC-822 `"Name" <email>` entries; we strip the angle-bracketed address before
- // matching against the normalized suppression identifier.
- private async buildSuppressionSkipReason(
- teamId: number,
- params: CyclotronInvocationQueueParametersEmailType,
- options: SuppressionCheckOptions
- ): Promise<string | null> {
- const recipients: string[] = []
- if (params.to?.email && params.to.email.trim()) {
- recipients.push(params.to.email.trim())
- }
- recipients.push(...extractEmailsFromAddressList(params.cc))
- recipients.push(...extractEmailsFromAddressList(params.bcc))
- if (recipients.length === 0) {
- return null
- }
-
- const results = await Promise.all(
- recipients.map(async (email) => ({
- email,
- suppressed: await this.emailSuppressionService.isSuppressed(teamId, email, options),
- }))
- )
- const suppressed = results.filter((r) => r.suppressed).map((r) => r.email)
- if (suppressed.length === 0) {
- return null
- }
- return `Skipping send: recipient(s) on the suppression list — ${suppressed.join(', ')}`
- }
-
// Per-send tracking decision, combining two independent controls:
// 1. Message-level: `tracking_enabled` on the email step's config (via `hogFunction.metadata`,
// same as `message_category_type`). False is a hard off regardless of consent. Absent means
@@ -927,10 +922,11 @@ export class EmailService {
// so consent must hold for every recipient (same reasoning as the suppression check).
const recipients: string[] = []
if (params.to?.email && params.to.email.trim()) {
- recipients.push(params.to.email.trim())
+ recipients.push(unquoteMailbox(params.to.email))
}
- recipients.push(...extractEmailsFromAddressList(params.cc))
- recipients.push(...extractEmailsFromAddressList(params.bcc))
+ // Preferences are stored against bare addresses, so a quoted local part is looked up unquoted.
+ recipients.push(...extractEmailsFromAddressList(params.cc).map(unquoteMailbox))
+ recipients.push(...extractEmailsFromAddressList(params.bcc).map(unquoteMailbox))
const consents = await Promise.all(
recipients.map(async (email) => {
@@ -1181,7 +1177,7 @@ export class EmailService {
if (sendEmailParams.Content?.Simple) {
const unsubscribeHeaders = !isTransactionalEmail
? this.generateUnsubscribeHeaders(
- { team_id: result.invocation.teamId, identifier: params.to.email },
+ { team_id: result.invocation.teamId, identifier: unquoteMailbox(params.to.email) },
preferencesTokenSourceForInvocation(result.invocation)
)
: []
diff --git a/nodejs/src/cdp/services/messaging/helpers/suppressed-recipients.test.ts b/nodejs/src/cdp/services/messaging/helpers/suppressed-recipients.test.ts
new file mode 100644
index 000000000000..354ecd39b70f
--- /dev/null
+++ b/nodejs/src/cdp/services/messaging/helpers/suppressed-recipients.test.ts
@@ -0,0 +1,83 @@
+import { EmailRecipients, SuppressedRecipientsResult, removeSuppressedRecipients } from './suppressed-recipients'
+
+describe('removeSuppressedRecipients', () => {
+ const suppressed = new Set(['[email protected]', '[email protected]'])
+ const isSuppressed = (email: string): Promise<boolean> => Promise.resolve(suppressed.has(email))
+
+ it.each<[string, EmailRecipients, SuppressedRecipientsResult]>([
+ [
+ 'leaves the recipients unchanged when nobody is suppressed',
+ { to: { email: '[email protected]' }, cc: '[email protected]', bcc: '[email protected]' },
+ { skip: false, cc: '[email protected]', bcc: '[email protected]', removed: [] },
+ ],
+ [
+ 'removes suppressed cc and bcc entries and keeps the original form of the others',
+ {
+ to: { email: '[email protected]' },
+ cc: '"B" <[email protected]>, "Gone" <[email protected]>',
+ },
+ {
+ skip: false,
+ cc: '"B" <[email protected]>',
+ bcc: '',
+ },
+ ],
+ [
+ 'removes a suppressed bracketed address that has text after it',
+ { to: { email: '[email protected]' }, cc: '"Gone" <[email protected]> (old), [email protected]' },
+ { skip: false, cc: '[email protected]', bcc: '', removed: ['[email protected]'] },
+ ],
+ [
+ 'checks the mailbox, not an address inside a quoted display name',
+ {
+ to: { email: '[email protected]' },
+ cc: '"Bob <[email protected]>" <[email protected]>, "Doe, Jane" <[email protected]>',
+ },
+ { skip: false, cc: '"Doe Jane" <[email protected]>', bcc: '', removed: ['[email protected]'] },
+ ],
+ [
+ 'checks a quoted local part unquoted and keeps the quotes for delivery',
+ { to: { email: '[email protected]' }, cc: '"bounced"@example.com, "john doe"@example.com' },
+ { skip: false, cc: '"john doe"@example.com', bcc: '', removed: ['[email protected]'] },
+ ],
+ [
+ 'checks a quoted to address unquoted',
+ { to: { email: '"bounced"@example.com' }, cc: '[email protected]' },
+ {
+ skip: false,
+ promotedTo: { email: '[email protected]' },
+ cc: '',
+ bcc: '',
+ removed: ['[email protected]'],
+ },
+ ],
+ [
+ 'promotes the first deliverable cc address when to is suppressed',
+ {
+ to: { email: '[email protected]' },
+ },
+ {
+ skip: false,
+ promotedTo: { email: '[email protected]', name: 'Admin B' },
+ bcc: '',
+ },
+ ],
+ [
+ 'skips when to is suppressed and only bcc addresses are left',
+ { to: { email: '[email protected]' }, bcc: '[email protected]' },
+ { skip: true, removed: ['[email protected]'] },
+ ],
+ [
+ 'does not skip when there is no to address to check',
+ { to: { email: '' }, cc: '[email protected]' },
+ { skip: false, cc: '[email protected]', bcc: undefined, removed: [] },
+ ],
+ ])('%s', async (_name, recipients, expected) => {
+ expect(await removeSuppressedRecipients(recipients, isSuppressed)).toEqual(expected)
+ })
+})
diff --git a/nodejs/src/cdp/services/messaging/helpers/suppressed-recipients.ts b/nodejs/src/cdp/services/messaging/helpers/suppressed-recipients.ts
new file mode 100644
index 000000000000..df21672cfbf9
--- /dev/null
+++ b/nodejs/src/cdp/services/messaging/helpers/suppressed-recipients.ts
@@ -0,0 +1,115 @@
+import addressparser from 'nodemailer/lib/addressparser'
+
+export type EmailRecipients = {
+ to?: { email?: string }
+ cc?: string
+ bcc?: string
+}
+
+export type SuppressedRecipientsResult = {
+ // True when `to` is suppressed and no cc address can take its place.
+ skip: boolean
+ // Set when `to` is suppressed and the first deliverable cc address replaces it.
+ promotedTo?: { email: string; name?: string }
+ cc?: string
+ bcc?: string
+ removed: string[]
+}
+
+type ParsedAddress = { email: string; name?: string }
+
+// The suppression list stores bare addresses, so a quoted local part (`"jo"@x.com`) is checked unquoted.
+export const unquoteMailbox = (address: string): string => {
+ const at = address.lastIndexOf('@')
+ const local = address.slice(0, at).trim()
+ if (at < 0 || !/^".*"$/.test(local)) {
+ return address.trim()
+ }
+ return `${local.slice(1, -1).replace(/\\(.)/g, '$1')}@${address.slice(at + 1).trim()}`
+}
+
+// addressparser drops the quotes from a bare quoted local part, so they are added back for delivery.
+export const quoteMailbox = (email: string): string => {
+ const at = email.lastIndexOf('@')
+ const local = email.slice(0, at)
+ if (at < 0 || /^[A-Za-z0-9!#$%&'*+/=?^_`{|}~.-]+$/.test(local)) {
+ return email
+ }
+ return `"${local.replace(/(["\\])/g, '\\$1')}"${email.slice(at)}`
+}
+
+// Parses the list the way SES does (RFC 5322), so quoted display names, comments and commas inside
+// quotes never hide the mailbox that receives the email.
+const parseAddressList = (value: string | undefined): ParsedAddress[] =>
+ typeof value === 'string'
+ ? addressparser(value, { flatten: true })
+ .filter((entry) => entry.address.trim().length > 0)
+ .map((entry) => {
+ const name = entry.name.replace(/[\x00-\x1F\x7F"\\<>,;]/g, '').trim()
+ return { email: unquoteMailbox(entry.address), ...(name ? { name } : {}) }
+ })
+ : []
+
+// Rebuilt from the parsed parts, so delivery sends to exactly the address the suppression check saw.
+const formatAddress = ({ email, name }: ParsedAddress): string =>
+ name ? `"${name}" <${quoteMailbox(email)}>` : quoteMailbox(email)
+
+/**
+ * Removes the addresses on the team's suppression list from an email's recipients. SES delivers to
+ * every address in to, cc and bcc, so each one is checked.
+ *
+ * Suppressed cc and bcc addresses are dropped, so one bounced address on a shared thread does not
+ * stop delivery to everyone else. When `to` is suppressed, the first deliverable cc address becomes
+ * `to`. This keeps an email addressed to a group (for example, every admin of an account) going
+ * after the first address bounces. A bcc address is never promoted, because that would show a
+ * hidden recipient to everyone else on the email.
+ *
+ * Kept cc and bcc entries are rewritten from their parsed parts, so the consent check, the send caps
+ * and SES all see the address that was checked here.
+ */
+export const removeSuppressedRecipients = async (
+ recipients: EmailRecipients,
+ isSuppressed: (email: string) => Promise<boolean>
+): Promise<SuppressedRecipientsResult> => {
+ const removed: string[] = []
+ const keepDeliverable = async (entries: ParsedAddress[]): Promise<ParsedAddress[]> => {
+ const suppressed = await Promise.all(entries.map((entry) => isSuppressed(entry.email)))
+ return entries.filter((entry, i) => {
+ if (suppressed[i]) {
+ removed.push(entry.email)
+ }
+ return !suppressed[i]
+ })
+ }
+ const formatList = (original: string | undefined, entries: ParsedAddress[]): string | undefined =>
+ original === undefined ? undefined : entries.map(formatAddress).join(', ')
+
+ const toEmail = recipients.to?.email ? unquoteMailbox(recipients.to.email) : undefined
+ const toSuppressed = !!toEmail && (await isSuppressed(toEmail))
+ if (toEmail && toSuppressed) {
+ removed.push(toEmail)
+ }
+ const ccEntries = await keepDeliverable(parseAddressList(recipients.cc))
+ const bccEntries = await keepDeliverable(parseAddressList(recipients.bcc))
+
+ if (removed.length === 0) {
+ return {
+ skip: false,
+ cc: formatList(recipients.cc, ccEntries),
+ bcc: formatList(recipients.bcc, bccEntries),
+ removed,
+ }
+ }
+ if (toSuppressed && ccEntries.length === 0) {
+ return { skip: true, removed }
+ }
+ const promoted = toSuppressed ? ccEntries.shift() : undefined
+ const promotedTo = promoted ? { ...promoted, email: quoteMailbox(promoted.email) } : undefined
+ return {
+ skip: false,
+ promotedTo,
+ cc: ccEntries.map(formatAddress).join(', '),
+ bcc: bccEntries.map(formatAddress).join(', '),
+ removed,
+ }
+}
diff --git a/nodejs/src/cdp/services/messaging/recipient-preferences.service.test.ts b/nodejs/src/cdp/services/messaging/recipient-preferences.service.test.ts
index 90358f3f4c4f..b0edc411d6d0 100644
--- a/nodejs/src/cdp/services/messaging/recipient-preferences.service.test.ts
+++ b/nodejs/src/cdp/services/messaging/recipient-preferences.service.test.ts
@@ -397,71 +397,37 @@ describe('RecipientPreferencesService', () => {
expect(result).toBe('suppressed')
})
- // A suppressed address placed in cc or bcc must still block the send, because SES
- // delivers to every recipient list, not just `to`.
+ // Suppressed cc and bcc addresses are removed at send time, and a deliverable cc address
+ // replaces a suppressed `to`. The step is skipped only when no cc address is left.
it.each([
+ ['a suppressed cc', '[email protected]', { cc: '[email protected]' }, null],
+ ['a suppressed bcc', '[email protected]', { bcc: '[email protected]' }, null],
[
- 'cc RFC-822 bracketed',
- '"Blocked User" <[email protected]>',
+ 'a suppressed to with a deliverable cc',
+ { cc: '[email protected]' },
+ null,
],
[
- 'bcc mixed comma-separated list',
+ 'a suppressed to with only bcc left',
+ { bcc: '[email protected]' },
+ 'suppressed',
],
- ] as const)(
- 'skips when a suppressed address appears in %s',
- async (field, suppressedEmail, headerValue) => {
- await insertSuppressionRow(suppressedEmail)
- const action = createEmailAction(
- '123e4567-e89b-12d3-a456-426614174000',
- 'marketing'
- )
- const invocation = createFunctionStepInvocation(action)
- // Inject the cc/bcc into the resolved invocation inputs (this is what the
- // executor sees at send time after template resolution).
- const emailInputs = invocation.state.globals!.inputs!.email as {
- to: { email: string }
- cc?: string
- bcc?: string
- }
- if (field.startsWith('cc')) {
- emailInputs.cc = headerValue
- } else {
- emailInputs.bcc = headerValue
- }
-
- const result = await service.shouldSkipAction(invocation, action)
-
- expect(result).toBe('suppressed')
- }
- )
-
- it('does not skip when cc/bcc contain only non-suppressed addresses', async () => {
- // Sanity check: the CC/BCC scan must not over-suppress. `to` is not suppressed
- // and cc/bcc contain unrelated addresses → fall through to the opt-out path.
- const action = createEmailAction(
- '123e4567-e89b-12d3-a456-426614174000',
- 'marketing'
- )
+ ] as const)('handles %s', async (_label, to, extraInputs, expected) => {
+ await insertSuppressionRow('[email protected]')
+ await insertSuppressionRow('[email protected]')
+ await insertSuppressionRow('[email protected]')
+ const action = createEmailAction(to, '123e4567-e89b-12d3-a456-426614174000', 'marketing')
const invocation = createFunctionStepInvocation(action)
- const emailInputs = invocation.state.globals!.inputs!.email as {
- to: { email: string }
- cc?: string
- bcc?: string
- }
- emailInputs.bcc = '[email protected]'
+ // Inject the cc/bcc into the resolved invocation inputs (this is what the
+ // executor sees at send time after template resolution).
+ Object.assign(invocation.state.globals!.inputs!.email as object, extraInputs)
mockRecipientsManagerGet.mockResolvedValue(null)
const result = await service.shouldSkipAction(invocation, action)
- expect(result).toBeNull()
+ expect(result).toBe(expected)
})
})
})
diff --git a/nodejs/src/cdp/services/messaging/recipient-preferences.service.ts b/nodejs/src/cdp/services/messaging/recipient-preferences.service.ts
index fe308e069c55..6ccf81b71427 100644
--- a/nodejs/src/cdp/services/messaging/recipient-preferences.service.ts
+++ b/nodejs/src/cdp/services/messaging/recipient-preferences.service.ts
@@ -9,6 +9,7 @@ import { PersonsManagerService } from '../managers/persons-manager.service'
import { RecipientsManagerService } from '../managers/recipients-manager.service'
import { TeamWorkflowsConfigService } from '../managers/team-workflows-config.service'
import { EmailSuppressionService } from './email-suppression.service'
+import { removeSuppressedRecipients } from './helpers/suppressed-recipients'
type MessageFunctionActionType = 'function_email' | 'function_sms' | 'function_push'
@@ -18,22 +19,6 @@ type MessageAction = Extract<HogFlowAction, { type: MessageFunctionActionType }>
// reason instead of collapsing suppression and opt-out into a single "opted out" message.
export type RecipientSkipReason = 'suppressed' | 'opted_out'
-// Split a comma-separated address list and, for each entry, extract the bare email from an RFC-822
-// `"Name" <email@x>` form so it can be matched against normalized suppression identifiers.
-const extractEmailsFromAddressList = (value: unknown): string[] => {
- if (typeof value !== 'string' || value.trim().length === 0) {
- return []
- }
- return value
- .split(',')
- .map((raw) => {
- const trimmed = raw.trim()
- const bracketed = trimmed.match(/<([^>]+)>/)
- return (bracketed ? bracketed[1] : trimmed).trim()
- })
- .filter((addr) => addr.length > 0)
-}
-
// One Lua script, so two concurrent sends to one person cannot both pass with one slot left. Each slot
// is keyed on the step visit. The email queue and send retries run the same step visit again, so a
// visit that already holds a slot passes. That run also moves the slot score to now, because the email
@@ -151,32 +136,25 @@ export class RecipientPreferencesService {
return false
}
- // Check every destination address SES will see — `to`, `cc`, and `bcc`. A suppressed
- // address in any of the three blocks the send, not just when it appears in `to`.
+ // Skip only when `to` is suppressed and no cc address can take its place. EmailService
+ // removes the other suppressed addresses at send time, and the email still goes to the rest.
const emailInputs = invocation.state.globals.inputs?.email
- const to = emailInputs?.to?.email
- const recipients = [
- ...(typeof to === 'string' && to.trim() ? [to.trim()] : []),
- ...extractEmailsFromAddressList(emailInputs?.cc),
- ...extractEmailsFromAddressList(emailInputs?.bcc),
- ]
-
- if (recipients.length === 0) {
- return false
- }
-
try {
- const results = await Promise.all(
- recipients.map((email) =>
+ const result = await removeSuppressedRecipients(
+ {
+ to: { email: typeof emailInputs?.to?.email === 'string' ? emailInputs.to.email : undefined },
+ cc: typeof emailInputs?.cc === 'string' ? emailInputs.cc : undefined,
+ bcc: typeof emailInputs?.bcc === 'string' ? emailInputs.bcc : undefined,
+ },
+ (email) =>
this.emailSuppressionService.isSuppressed(invocation.teamId, email, {
transactional: action.config.message_category_type === 'transactional',
})
- )
)
- return results.some(Boolean)
+ return result.skip
} catch (error) {
// Fail open — never block a send on a suppression-lookup error.
- logger.error(`Failed to check suppression list for recipients ${recipients.join(', ')}:`, error)
+ logger.error(`Failed to check suppression list for team ${invocation.teamId}:`, error)
return false
}
}