feat: set first and last name for email

This commit is contained in:
Muhsin Keloth
2024-02-07 15:57:44 +05:30
parent ac5aee3c8d
commit 9ecb847d9b
2 changed files with 10 additions and 5 deletions
+7 -1
View File
@@ -1,4 +1,6 @@
module MailboxHelper
include ContactHelper
private
def create_message
@@ -87,11 +89,15 @@ module MailboxHelper
end
def create_contact
name_parts = split_first_and_last_name(identify_contact_name)
first_name = name_parts[:first_name]
last_name = name_parts[:last_name]
@contact_inbox = ::ContactInboxWithContactBuilder.new(
source_id: processed_mail.original_sender,
inbox: @inbox,
contact_attributes: {
name: identify_contact_name,
name: first_name,
last_name: last_name,
email: processed_mail.original_sender,
additional_attributes: {
source_id: "email:#{processed_mail.message_id}"
+3 -4
View File
@@ -89,9 +89,9 @@ RSpec.describe SupportMailbox 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)
expect(conversation.contact.name).to eq('Sony')
expect(conversation.contact.last_name).to eq('Mathew')
end
it 'add the mail content as new message on the conversation' do
@@ -178,10 +178,9 @@ RSpec.describe SupportMailbox 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)
expect(conversation.contact.name).to eq('ACME')
end
end