Files
chatwoot/app/mailboxes/reply_mailbox.rb
T
Shivam Mishra 84993485b2 refactor: unify email routing with NewConversationStrategy fallback
Replace separate SupportMailbox with NewConversationStrategy as the
final fallback in the conversation finder chain. This prevents emails
from being silently dropped when routing rules match but no existing
conversation is found.

Previously, emails could route to ReplyMailbox (based on headers or
channel matching) but get dropped if ReferencesStrategy failed to find
a conversation. This happened when two Chatwoot accounts emailed each
other - References header contained conversation IDs from both accounts,
routing matched globally, but scoped queries found nothing.
2025-10-30 17:09:35 +05:30

23 lines
515 B
Ruby

class ReplyMailbox < ApplicationMailbox
attr_accessor :conversation, :processed_mail
before_processing :find_conversation
def process
# ConversationFinder with NewConversationStrategy ensures @conversation is always present
decorate_mail
create_message
add_attachments_to_message
end
private
def find_conversation
@conversation = Mailbox::ConversationFinder.new(mail).find
end
def decorate_mail
@processed_mail = MailPresenter.new(mail, @conversation.account)
end
end