From f64a7810787faf33fdd62dbd1a16dde0947607aa Mon Sep 17 00:00:00 2001 From: Shivam Mishra Date: Thu, 30 Oct 2025 16:00:12 +0530 Subject: [PATCH] chore: add comment on fallback account id reference --- .../in_reply_to_strategy.rb | 8 ++++++++ .../conversation_finder_strategies/references_strategy.rb | 8 ++++++++ 2 files changed, 16 insertions(+) diff --git a/app/services/mailbox/conversation_finder_strategies/in_reply_to_strategy.rb b/app/services/mailbox/conversation_finder_strategies/in_reply_to_strategy.rb index 6bfe5f7eb..b14f851f5 100644 --- a/app/services/mailbox/conversation_finder_strategies/in_reply_to_strategy.rb +++ b/app/services/mailbox/conversation_finder_strategies/in_reply_to_strategy.rb @@ -1,6 +1,14 @@ class Mailbox::ConversationFinderStrategies::InReplyToStrategy < Mailbox::ConversationFinderStrategies::BaseStrategy # Patterns from ApplicationMailbox MESSAGE_PATTERN = %r{conversation/([a-zA-Z0-9-]+)/messages/(\d+)@} + + # FALLBACK_PATTERN is used when building In-Reply-To headers in ConversationReplyMailer + # when there's no actual message to reply to (see app/mailers/conversation_reply_mailer.rb#in_reply_to_email). + # This happens when: + # - A conversation is started by an agent (no incoming message yet) + # - The conversation originated from a non-email channel (widget, WhatsApp, etc.) but is now using email + # - The incoming message doesn't have email metadata with a message_id + # In these cases, we use a conversation-level identifier instead of a message-level one. FALLBACK_PATTERN = %r{account/(\d+)/conversation/([a-zA-Z0-9-]+)@} def find diff --git a/app/services/mailbox/conversation_finder_strategies/references_strategy.rb b/app/services/mailbox/conversation_finder_strategies/references_strategy.rb index d9fdad485..d2b017364 100644 --- a/app/services/mailbox/conversation_finder_strategies/references_strategy.rb +++ b/app/services/mailbox/conversation_finder_strategies/references_strategy.rb @@ -1,6 +1,14 @@ class Mailbox::ConversationFinderStrategies::ReferencesStrategy < Mailbox::ConversationFinderStrategies::BaseStrategy # Patterns from ApplicationMailbox MESSAGE_PATTERN = %r{conversation/([a-zA-Z0-9-]+)/messages/(\d+)@} + + # FALLBACK_PATTERN is used when building References headers in ConversationReplyMailer + # when there's no actual message to reply to (see app/mailers/conversation_reply_mailer.rb#in_reply_to_email). + # This happens when: + # - A conversation is started by an agent (no incoming message yet) + # - The conversation originated from a non-email channel (widget, WhatsApp, etc.) but is now using email + # - The incoming message doesn't have email metadata with a message_id + # In these cases, we use a conversation-level identifier instead of a message-level one. FALLBACK_PATTERN = %r{account/(\d+)/conversation/([a-zA-Z0-9-]+)@} def find