chore: Use the name of the sender from the mail object
if the sender email is Sony Mathew <Sony@chatwoot.com> Contact should be built with Sony Mathew Fixes #2911
This commit is contained in:
@@ -32,7 +32,9 @@ RSpec.describe SupportMailbox, type: :mailbox do
|
||||
end
|
||||
|
||||
it 'create a new contact as the sender of the email' do
|
||||
email_sender = Mail::Address.new(support_mail.mail[:from].value).name
|
||||
expect(conversation.messages.last.sender.email).to eq(support_mail.mail.from.first)
|
||||
expect(conversation.contact.name).to eq(email_sender)
|
||||
end
|
||||
|
||||
it 'add the mail content as new message on the conversation' do
|
||||
@@ -52,6 +54,18 @@ RSpec.describe SupportMailbox, type: :mailbox do
|
||||
end
|
||||
end
|
||||
|
||||
describe 'Sender without name' do
|
||||
let(:support_mail_without_sender_name) { create_inbound_email_from_fixture('support_without_sender_name.eml') }
|
||||
let(:described_subject) { described_class.receive support_mail_without_sender_name }
|
||||
|
||||
it 'create a new contact with the email' do
|
||||
described_subject
|
||||
email_sender = support_mail_without_sender_name.mail.from.first.split('@').first
|
||||
expect(conversation.messages.last.sender.email).to eq(support_mail.mail.from.first)
|
||||
expect(conversation.contact.name).to eq(email_sender)
|
||||
end
|
||||
end
|
||||
|
||||
describe 'handle inbox contacts' do
|
||||
let(:contact) { create(:contact, account: account, email: support_mail.mail.from.first) }
|
||||
let(:contact_inbox) { create(:contact_inbox, inbox: channel_email.inbox, contact: contact) }
|
||||
@@ -76,7 +90,10 @@ RSpec.describe SupportMailbox, type: :mailbox do
|
||||
|
||||
it 'create new contact with original sender' do
|
||||
described_subject
|
||||
email_sender = Mail::Address.new(group_sender_support_mail.mail[:from].value).name
|
||||
|
||||
expect(conversation.contact.email).to eq(group_sender_support_mail.mail['X-Original-Sender'].value)
|
||||
expect(conversation.contact.name).to eq(email_sender)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user