diff --git a/apps/web/app/api/ai/cold-email/controller.ts b/apps/web/app/api/ai/cold-email/controller.ts index dfe0093ae..f2f3a8a16 100644 --- a/apps/web/app/api/ai/cold-email/controller.ts +++ b/apps/web/app/api/ai/cold-email/controller.ts @@ -124,6 +124,7 @@ export async function runColdEmailBlocker(options: { const response = await isColdEmail(options); if (response.isColdEmail) await blockColdEmail({ ...options, aiReason: response.aiReason || null }); + return response; } async function blockColdEmail(options: { diff --git a/apps/web/app/api/google/webhook/process-history.ts b/apps/web/app/api/google/webhook/process-history.ts index 25dda498f..6ae3c4090 100644 --- a/apps/web/app/api/google/webhook/process-history.ts +++ b/apps/web/app/api/google/webhook/process-history.ts @@ -374,7 +374,7 @@ async function processHistoryItem( snippet: message.snippet, }); - await runColdEmailBlocker({ + const response = await runColdEmailBlocker({ hasPreviousEmail, email: { from: message.headers.from, @@ -386,6 +386,11 @@ async function processHistoryItem( gmail, user, }); + + if (response.isColdEmail) { + logger.info("Skipping. Cold email detected."); + return; + } } // categorize a sender if we haven't already