From 6ddc99d066dfac878cf880ec6002505c7ba41494 Mon Sep 17 00:00:00 2001 From: Pranav Raj S Date: Thu, 24 Aug 2023 03:49:17 -0700 Subject: [PATCH] fix: Update the in_reply_to to logic to use processed_mail (#7793) --- app/mailboxes/imap/imap_mailbox.rb | 2 +- spec/mailboxes/imap/imap_mailbox_spec.rb | 9 +++++++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/app/mailboxes/imap/imap_mailbox.rb b/app/mailboxes/imap/imap_mailbox.rb index fffba4307..57d30253a 100644 --- a/app/mailboxes/imap/imap_mailbox.rb +++ b/app/mailboxes/imap/imap_mailbox.rb @@ -56,7 +56,7 @@ class Imap::ImapMailbox end def in_reply_to - @inbound_mail.in_reply_to + @processed_mail.in_reply_to end def find_message_by_references diff --git a/spec/mailboxes/imap/imap_mailbox_spec.rb b/spec/mailboxes/imap/imap_mailbox_spec.rb index 07881de25..798f21112 100644 --- a/spec/mailboxes/imap/imap_mailbox_spec.rb +++ b/spec/mailboxes/imap/imap_mailbox_spec.rb @@ -171,5 +171,14 @@ RSpec.describe Imap::ImapMailbox do expect(references_email.mail.references).to include('test-reference-id-2') end end + + context 'when a reply for a conversation has multiple in_reply_to' do + let(:multiple_in_reply_to_mail) { create_inbound_email_from_fixture('multiple_in_reply_to.eml').mail } + + it 'creates conversation taking the first in_reply_to email' do + class_instance.process(multiple_in_reply_to_mail, channel) + expect(conversation.additional_attributes['in_reply_to']).to eq(multiple_in_reply_to_mail.in_reply_to.first) + end + end end end