diff --git a/app/services/mailbox/conversation_finder_strategies/new_conversation_strategy.rb b/app/services/mailbox/conversation_finder_strategies/new_conversation_strategy.rb index f084ed708..c1c6b256e 100644 --- a/app/services/mailbox/conversation_finder_strategies/new_conversation_strategy.rb +++ b/app/services/mailbox/conversation_finder_strategies/new_conversation_strategy.rb @@ -8,9 +8,7 @@ class Mailbox::ConversationFinderStrategies::NewConversationStrategy < Mailbox:: # It should be used as the last strategy in the chain to ensure emails are never dropped. def find channel = EmailChannelFinder.new(mail).perform - - # Match old SupportMailbox behavior - raise error when no channel found - raise 'Email channel/inbox not found' if channel.nil? + return nil unless channel # No valid channel found @account = channel.account @inbox = channel.inbox diff --git a/spec/mailboxes/reply_mailbox_spec.rb b/spec/mailboxes/reply_mailbox_spec.rb index 18cfcb213..2658731bc 100644 --- a/spec/mailboxes/reply_mailbox_spec.rb +++ b/spec/mailboxes/reply_mailbox_spec.rb @@ -687,7 +687,8 @@ RSpec.describe ReplyMailbox do bcc_mail.mail['to'] = nil bcc_mail.mail['bcc'] = 'care@example.com' - expect { described_class.receive bcc_mail }.to raise_error('Email channel/inbox not found') + described_class.receive bcc_mail + expect(conversation.present?).to be(false) end end end diff --git a/spec/services/mailbox/conversation_finder_strategies/new_conversation_strategy_spec.rb b/spec/services/mailbox/conversation_finder_strategies/new_conversation_strategy_spec.rb index 26df915fa..f790c97d9 100644 --- a/spec/services/mailbox/conversation_finder_strategies/new_conversation_strategy_spec.rb +++ b/spec/services/mailbox/conversation_finder_strategies/new_conversation_strategy_spec.rb @@ -111,13 +111,13 @@ RSpec.describe Mailbox::ConversationFinderStrategies::NewConversationStrategy do mail.to = ['nonexistent@example.com'] end - it 'raises an error' do + it 'returns nil' do strategy = described_class.new(mail) expect do - strategy.find - end.to raise_error('Email channel/inbox not found') - .and not_change(Conversation, :count) + result = strategy.find + expect(result).to be_nil + end.not_to change(Conversation, :count) end end