feat: Store first name and last name for the supporting channels
This commit is contained in:
@@ -51,6 +51,8 @@ class ContactInboxWithContactBuilder
|
||||
def create_contact
|
||||
account.contacts.create!(
|
||||
name: contact_attributes[:name] || ::Haikunator.haikunate(1000),
|
||||
last_name: contact_attributes[:last_name] || '',
|
||||
middle_name: contact_attributes[:middle_name] || '',
|
||||
phone_number: contact_attributes[:phone_number],
|
||||
email: contact_attributes[:email],
|
||||
identifier: contact_attributes[:identifier],
|
||||
|
||||
@@ -104,7 +104,8 @@ class Messages::Facebook::MessageBuilder < Messages::Messenger::MessageBuilder
|
||||
|
||||
def process_contact_params_result(result)
|
||||
{
|
||||
name: "#{result['first_name'] || 'John'} #{result['last_name'] || 'Doe'}",
|
||||
name: result['first_name'] || 'John',
|
||||
last_name: result['last_name'] || 'Doe',
|
||||
account_id: @inbox.account_id,
|
||||
avatar_url: result['profile_pic']
|
||||
}
|
||||
|
||||
@@ -71,7 +71,8 @@ class Telegram::IncomingMessageService
|
||||
|
||||
def contact_attributes
|
||||
{
|
||||
name: "#{telegram_params_first_name} #{telegram_params_last_name}",
|
||||
name: telegram_params_first_name,
|
||||
last_name: telegram_params_last_name,
|
||||
additional_attributes: additional_attributes
|
||||
}
|
||||
end
|
||||
|
||||
@@ -13,6 +13,7 @@ describe ContactInboxWithContactBuilder do
|
||||
inbox: inbox,
|
||||
contact_attributes: {
|
||||
name: 'Contact',
|
||||
last_name: '1',
|
||||
phone_number: '+1234567890',
|
||||
email: 'testemail@example.com'
|
||||
}
|
||||
@@ -35,6 +36,7 @@ describe ContactInboxWithContactBuilder do
|
||||
|
||||
expect(contact_inbox.contact.id).not_to eq(contact.id)
|
||||
expect(contact_inbox.contact.name).to eq('Contact')
|
||||
expect(contact_inbox.contact.last_name).to eq('1')
|
||||
expect(contact_inbox.contact.custom_attributes).to eq({ 'test' => 'test' })
|
||||
expect(contact_inbox.inbox_id).to eq(inbox.id)
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user