From cec91890fe47cbf1f80a6b651568d4daec8b6b33 Mon Sep 17 00:00:00 2001 From: Patryk Bajer Date: Wed, 24 Jun 2026 10:46:47 +0200 Subject: [PATCH] fix: update Message-ID format to include timestamp for uniqueness --- src/channels/email/shared/MessageIdUtils.ts | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/channels/email/shared/MessageIdUtils.ts b/src/channels/email/shared/MessageIdUtils.ts index ad4f65d0..e103aee3 100644 --- a/src/channels/email/shared/MessageIdUtils.ts +++ b/src/channels/email/shared/MessageIdUtils.ts @@ -13,8 +13,9 @@ export function extractDomainFromEmail(email?: string): string | undefined { * Generates a unique Message-ID for an email. * * When a conversation ID is provided, the format is: - * <{uuid}.{YYYYMMDD}.{HHMMSS}@domain> - * where {uuid} is the conversation ID without the "conv_" prefix. + * <{uuid}.{timestamp}@domain> + * where {uuid} is the conversation ID without the "conv_" prefix, + * and {timestamp} is Date.now() in base-36 to ensure uniqueness per message. * * Falls back to a random ID if no conversation ID is provided. * Uses the given domain, or `bonsai.ai` as a last resort. @@ -24,7 +25,8 @@ export function generateEmailMessageId(conversationId?: string, domain?: string) if (conversationId) { const id = conversationId.replace(/^conv_/, '').replace(/-/g, ''); - return `<${id}@${fallbackDomain}>`; + const timestamp = Date.now().toString(36); + return `<${id}.${timestamp}@${fallbackDomain}>`; } return `<${randomBytes(16).toString('hex')}@${fallbackDomain}>`;