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.
23 lines
515 B
Ruby
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
|