Compare commits

...
Author SHA1 Message Date
Muhsin KelothandGitHub aef9f05b9d Merge branch 'develop' into CW-3013 2024-03-11 21:50:30 +05:30
Muhsin Keloth 8c922fd8df Update incoming_message_service_spec.rb 2024-03-11 21:50:16 +05:30
Muhsin Keloth ec283f6657 fix: specs 2024-03-11 20:17:55 +05:30
Muhsin Keloth 4c6954fefc chore: code cleanup 2024-03-11 16:15:23 +05:30
Muhsin KelothandGitHub 9ef93fda87 Merge branch 'develop' into CW-3013 2024-03-11 15:24:54 +05:30
Muhsin KelothandGitHub bca3d98268 Merge branch 'develop' into CW-3013 2024-02-12 16:21:48 +05:30
Muhsin KelothandGitHub 95cd68813f Merge branch 'develop' into CW-3013 2024-02-12 14:32:30 +05:30
Muhsin Keloth ac85ccf2cf Merge branch 'CW-3013' of https://github.com/chatwoot/chatwoot into CW-3013 2024-02-08 16:24:35 +05:30
Muhsin Keloth 78a4dce5b9 fix: Contact create logic 2024-02-08 16:22:13 +05:30
Muhsin KelothandGitHub 28c1dd0a26 Merge branch 'develop' into CW-3013 2024-02-08 15:47:56 +05:30
Muhsin Keloth 377aeb8087 chore: fix specs 2024-02-08 15:47:31 +05:30
Muhsin KelothandGitHub 117a1405e5 Merge branch 'develop' into CW-3013 2024-02-08 11:25:41 +05:30
Muhsin Keloth 1f8ac8a59c Merge branch 'CW-3013' of https://github.com/chatwoot/chatwoot into CW-3013 2024-02-07 17:32:41 +05:30
Muhsin Keloth 78855afe8b Update incoming_message_service_spec.rb 2024-02-07 17:32:39 +05:30
Muhsin Keloth 2566155e04 Update incoming_message_service_spec.rb 2024-02-07 16:20:51 +05:30
Muhsin Keloth ce6ae2cc47 Merge branch 'CW-3013' of https://github.com/chatwoot/chatwoot into CW-3013 2024-02-07 15:57:55 +05:30
Muhsin Keloth 9ecb847d9b feat: set first and last name for email 2024-02-07 15:57:44 +05:30
Muhsin KelothandGitHub fdffc39663 Merge branch 'develop' into CW-3013 2024-02-07 15:50:20 +05:30
Muhsin Keloth ac5aee3c8d Update incoming_message_whatsapp_cloud_service_spec.rb 2024-02-07 15:50:08 +05:30
Muhsin KelothandGitHub 94ede8a654 Merge branch 'develop' into CW-3013 2024-02-07 14:42:32 +05:30
Muhsin Keloth 07a7c1eb8b fix: specs 2024-02-07 14:34:11 +05:30
Muhsin Keloth b125ac1ad6 Update message_builder.rb 2024-02-07 14:05:32 +05:30
Muhsin Keloth ecfa19bb1a fix: route push fixes 2024-02-07 14:02:29 +05:30
Muhsin KelothandGitHub 733a851607 Merge branch 'develop' into CW-3013 2024-02-07 13:35:57 +05:30
Muhsin Keloth 8c4b13b737 feat: set first and last name for WhatsApp 2024-02-07 13:33:57 +05:30
Muhsin Keloth 1c73aa9ef4 feat: set first and last name for instagram 2024-02-07 13:20:41 +05:30
Muhsin Keloth bafaf9c786 feat: add split_first_and_last_name helper 2024-02-07 12:42:53 +05:30
Muhsin KelothandGitHub 75dd77a92d Merge branch 'develop' into CW-3013 2024-02-07 12:38:11 +05:30
Muhsin KelothandGitHub ffbc7cb846 Merge branch 'develop' into CW-3013 2024-01-29 21:18:27 +05:30
Muhsin Keloth d88d195e73 fix: specs 2024-01-29 21:06:08 +05:30
Muhsin KelothandGitHub 27c51a0bdf Merge branch 'develop' into CW-3013 2024-01-29 17:11:52 +05:30
Muhsin Keloth 822411d804 feat: Store first name and last name for the supporting channels 2024-01-29 17:10:37 +05:30
17 changed files with 95 additions and 40 deletions
+1
View File
@@ -62,6 +62,7 @@ Metrics/ModuleLength:
Exclude:
- lib/seeders/message_seeder.rb
- spec/support/slack_stubs.rb
- app/mailboxes/mailbox_helper.rb
Rails/ApplicationController:
Exclude:
- 'app/controllers/api/v1/widget/messages_controller.rb'
@@ -3,6 +3,7 @@
# for contact inbox logic it uses the contact inbox builder
class ContactInboxWithContactBuilder
include ContactHelper
pattr_initialize [:inbox!, :contact_attributes!, :source_id, :hmac_verified]
def perform
@@ -49,8 +50,12 @@ class ContactInboxWithContactBuilder
end
def create_contact
# TODO: Consider name as first_name and we will change the name to full_name in the future
name, middle_name, last_name = extract_name_parts
account.contacts.create!(
name: contact_attributes[:name] || ::Haikunator.haikunate(1000),
name: name,
middle_name: middle_name,
last_name: last_name,
phone_number: contact_attributes[:phone_number],
email: contact_attributes[:email],
identifier: contact_attributes[:identifier],
@@ -59,6 +64,20 @@ class ContactInboxWithContactBuilder
)
end
def extract_name_parts
# Return a generated name if name attribute is blank
return [::Haikunator.haikunate(1000), '', ''] if contact_attributes[:name].blank?
# Return the all name parts if middle_name or last_name is present
if contact_attributes[:middle_name].present? || contact_attributes[:last_name].present?
return [contact_attributes[:name], contact_attributes[:middle_name], contact_attributes[:last_name]]
end
# If name is present, split it into first and last name
name_parts = parse_name(contact_attributes[:name])
[name_parts[:first_name], name_parts[:middle_name], name_parts[:last_name]]
end
def find_contact
contact = find_contact_by_identifier(contact_attributes[:identifier])
contact ||= find_contact_by_email(contact_attributes[:email])
@@ -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']
}
+1 -1
View File
@@ -31,7 +31,7 @@ module ContactHelper
end
def valid_number?(full_name)
full_name.gsub(/\s+/, '').match?(/\A\+?\d+\z/)
TelephoneNumber.parse(full_name).valid?
end
def single_word_name_hash(full_name)
+9 -1
View File
@@ -1,4 +1,6 @@
module MailboxHelper
include ContactHelper
private
def create_message
@@ -96,11 +98,17 @@ module MailboxHelper
end
def create_contact
name_parts = parse_name(identify_contact_name)
first_name = name_parts[:first_name]
middle_name = name_parts[:middle_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,
middle_name: middle_name,
last_name: last_name,
email: processed_mail.original_sender,
additional_attributes: {
source_id: "email:#{processed_mail.message_id}"
+6 -1
View File
@@ -20,6 +20,7 @@
class Channel::FacebookPage < ApplicationRecord
include Channelable
include Reauthorizable
include ContactHelper
self.table_name = 'channel_facebook_pages'
@@ -37,10 +38,14 @@ class Channel::FacebookPage < ApplicationRecord
end
def create_contact_inbox(instagram_id, name)
name_parts = parse_name(name)
first_name = name_parts[:first_name]
last_name = name_parts[:last_name]
middle_name = name_parts[:middle_name]
@contact_inbox = ::ContactInboxWithContactBuilder.new({
source_id: instagram_id,
inbox: inbox,
contact_attributes: { name: name }
contact_attributes: { name: first_name, last_name: last_name, middle_name: middle_name }
}).perform
end
+3
View File
@@ -37,6 +37,9 @@
# rubocop:enable Layout/LineLength
# Notes
# TODO: We are considering the "name" as "first_name". We will update it to "first_name" in the future.
class Contact < ApplicationRecord
include Avatarable
include AvailabilityStatusable
@@ -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
@@ -3,7 +3,7 @@
# https://developers.facebook.com/docs/whatsapp/api/media/
class Whatsapp::IncomingMessageBaseService
include ::Whatsapp::IncomingMessageServiceHelpers
include ContactHelper
pattr_initialize [:inbox!, :params!]
def perform
@@ -84,10 +84,17 @@ class Whatsapp::IncomingMessageBaseService
waid = processed_waid(contact_params[:wa_id])
name = contact_params.dig(:profile, :name)
name_parts = parse_name(name)
first_name = name_parts[:first_name]
middle_name = name_parts[:middle_name]
last_name = name_parts[:last_name]
contact_inbox = ::ContactInboxWithContactBuilder.new(
source_id: waid,
inbox: inbox,
contact_attributes: { name: contact_params.dig(:profile, :name), phone_number: "+#{@processed_params[:messages].first[:from]}" }
contact_attributes: { name: first_name, last_name: last_name, middle_name: middle_name,
phone_number: "+#{@processed_params[:messages].first[:from]}" }
).perform
@contact_inbox = contact_inbox
@@ -13,6 +13,7 @@ describe ContactInboxWithContactBuilder do
inbox: inbox,
contact_attributes: {
name: 'Contact',
last_name: '1',
phone_number: '+1234567890',
email: 'testemail@example.com'
}
@@ -27,6 +28,7 @@ describe ContactInboxWithContactBuilder do
inbox: inbox,
contact_attributes: {
name: 'Contact',
last_name: '1',
phone_number: '+1234567890',
email: 'testemail@example.com',
custom_attributes: { test: 'test' }
@@ -35,6 +37,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
@@ -28,7 +28,8 @@ describe Messages::Facebook::MessageBuilder do
contact = facebook_channel.inbox.contacts.first
message = facebook_channel.inbox.messages.first
expect(contact.name).to eq('Jane Dae')
expect(contact.name).to eq('Jane')
expect(contact.last_name).to eq('Dae')
expect(message.content).to eq('facebook message')
end
@@ -53,10 +54,11 @@ describe Messages::Facebook::MessageBuilder do
contact = facebook_channel.inbox.contacts.first
# Refer: https://github.com/chatwoot/chatwoot/pull/3016 for this check
default_name = 'John Doe'
default_name = 'John'
expect(facebook_channel.inbox.reload.contacts.count).to eq(1)
expect(contact.name).to eq(default_name)
expect(contact.last_name).to eq('Doe')
end
end
end
+2 -2
View File
@@ -63,8 +63,8 @@ RSpec.describe ContactHelper do
end
it 'handle name with mobile number with spaces correctly' do
full_name = '+1 234 567 890'
expected_result = { first_name: '+1 234 567 890', last_name: nil, middle_name: nil, prefix: nil, suffix: nil }
full_name = '+1 423-423-4234'
expected_result = { first_name: '+1 423-423-4234', last_name: nil, middle_name: nil, prefix: nil, suffix: nil }
expect(helper.parse_name(full_name)).to eq(expected_result)
end
+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
@@ -156,7 +156,7 @@ describe Line::IncomingMessageService do
)
described_class.new(inbox: line_channel.inbox, params: params).perform
expect(line_channel.inbox.conversations).not_to eq(0)
expect(Contact.all.first.name).to eq('LINE Test')
expect(Contact.all.first.name).to eq('LINE')
expect(Contact.all.first.additional_attributes['social_line_user_id']).to eq('U4af4980629')
expect(line_channel.inbox.messages.first.content).to eq('Hello, world')
end
@@ -177,7 +177,7 @@ describe Line::IncomingMessageService do
)
described_class.new(inbox: line_channel.inbox, params: sticker_params).perform
expect(line_channel.inbox.conversations).not_to eq(0)
expect(Contact.all.first.name).to eq('LINE Test')
expect(Contact.all.first.name).to eq('LINE')
expect(line_channel.inbox.messages.first.content).to eq('![sticker-52002738](https://stickershop.line-scdn.net/stickershop/v1/sticker/52002738/iphone/sticker.png)')
end
end
@@ -204,7 +204,7 @@ describe Line::IncomingMessageService do
)
described_class.new(inbox: line_channel.inbox, params: image_params).perform
expect(line_channel.inbox.conversations).not_to eq(0)
expect(Contact.all.first.name).to eq('LINE Test')
expect(Contact.all.first.name).to eq('LINE')
expect(Contact.all.first.additional_attributes['social_line_user_id']).to eq('U4af4980629')
expect(line_channel.inbox.messages.first.content).to be_nil
expect(line_channel.inbox.messages.first.attachments.first.file_type).to eq('image')
@@ -234,7 +234,7 @@ describe Line::IncomingMessageService do
)
described_class.new(inbox: line_channel.inbox, params: video_params).perform
expect(line_channel.inbox.conversations).not_to eq(0)
expect(Contact.all.first.name).to eq('LINE Test')
expect(Contact.all.first.name).to eq('LINE')
expect(Contact.all.first.additional_attributes['social_line_user_id']).to eq('U4af4980629')
expect(line_channel.inbox.messages.first.content).to be_nil
expect(line_channel.inbox.messages.first.attachments.first.file_type).to eq('video')
@@ -51,7 +51,8 @@ describe Telegram::IncomingMessageService do
}.with_indifferent_access
described_class.new(inbox: telegram_channel.inbox, params: params).perform
expect(telegram_channel.inbox.conversations.count).not_to eq(0)
expect(Contact.all.first.name).to eq('Sojan Jose')
expect(Contact.all.first.name).to eq('Sojan')
expect(Contact.all.first.last_name).to eq('Jose')
expect(telegram_channel.inbox.messages.first.content).to eq('test')
end
end
@@ -64,7 +65,8 @@ describe Telegram::IncomingMessageService do
}.with_indifferent_access
described_class.new(inbox: telegram_channel.inbox, params: params).perform
expect(telegram_channel.inbox.conversations.count).not_to eq(0)
expect(Contact.all.first.name).to eq('Sojan Jose')
expect(Contact.all.first.name).to eq('Sojan')
expect(Contact.all.first.last_name).to eq('Jose')
expect(Contact.all.first.additional_attributes['social_telegram_user_id']).to eq(23)
expect(Contact.all.first.additional_attributes['social_telegram_user_name']).to eq('sojan')
expect(telegram_channel.inbox.messages.first.content).to eq('test')
@@ -106,7 +108,7 @@ describe Telegram::IncomingMessageService do
}.with_indifferent_access
described_class.new(inbox: telegram_channel.inbox, params: params).perform
expect(telegram_channel.inbox.conversations.count).not_to eq(0)
expect(Contact.all.first.name).to eq('Sojan Jose')
expect(Contact.all.first.name).to eq('Sojan')
expect(Contact.all.first.additional_attributes['social_telegram_user_id']).to eq(23)
expect(Contact.all.first.additional_attributes['social_telegram_user_name']).to eq('sojan')
expect(telegram_channel.inbox.messages.first.attachments.first.file_type).to eq('audio')
@@ -127,7 +129,7 @@ describe Telegram::IncomingMessageService do
}.with_indifferent_access
described_class.new(inbox: telegram_channel.inbox, params: params).perform
expect(telegram_channel.inbox.conversations.count).not_to eq(0)
expect(Contact.all.first.name).to eq('Sojan Jose')
expect(Contact.all.first.name).to eq('Sojan')
expect(telegram_channel.inbox.messages.first.attachments.first.file_type).to eq('image')
end
end
@@ -152,7 +154,7 @@ describe Telegram::IncomingMessageService do
}.with_indifferent_access
described_class.new(inbox: telegram_channel.inbox, params: params).perform
expect(telegram_channel.inbox.conversations.count).not_to eq(0)
expect(Contact.all.first.name).to eq('Sojan Jose')
expect(Contact.all.first.name).to eq('Sojan')
expect(telegram_channel.inbox.messages.first.attachments.first.file_type).to eq('image')
end
end
@@ -174,7 +176,7 @@ describe Telegram::IncomingMessageService do
}.with_indifferent_access
described_class.new(inbox: telegram_channel.inbox, params: params).perform
expect(telegram_channel.inbox.conversations.count).not_to eq(0)
expect(Contact.all.first.name).to eq('Sojan Jose')
expect(Contact.all.first.name).to eq('Sojan')
expect(telegram_channel.inbox.messages.first.attachments.first.file_type).to eq('video')
end
end
@@ -193,7 +195,7 @@ describe Telegram::IncomingMessageService do
}.with_indifferent_access
described_class.new(inbox: telegram_channel.inbox, params: params).perform
expect(telegram_channel.inbox.conversations.count).not_to eq(0)
expect(Contact.all.first.name).to eq('Sojan Jose')
expect(Contact.all.first.name).to eq('Sojan')
expect(telegram_channel.inbox.messages.first.attachments.first.file_type).to eq('audio')
end
end
@@ -214,7 +216,7 @@ describe Telegram::IncomingMessageService do
}.with_indifferent_access
described_class.new(inbox: telegram_channel.inbox, params: params).perform
expect(telegram_channel.inbox.conversations.count).not_to eq(0)
expect(Contact.all.first.name).to eq('Sojan Jose')
expect(Contact.all.first.name).to eq('Sojan')
expect(telegram_channel.inbox.messages.first.attachments.first.file_type).to eq('file')
end
end
@@ -252,7 +254,7 @@ describe Telegram::IncomingMessageService do
}.with_indifferent_access
described_class.new(inbox: telegram_channel.inbox, params: params).perform
expect(telegram_channel.inbox.conversations.count).not_to eq(0)
expect(Contact.all.first.name).to eq('Sojan Jose')
expect(Contact.all.first.name).to eq('Sojan')
expect(telegram_channel.inbox.messages.first.attachments.first.file_type).to eq('location')
end
end
@@ -280,7 +282,8 @@ describe Telegram::IncomingMessageService do
described_class.new(inbox: telegram_channel.inbox, params: params).perform
expect(telegram_channel.inbox.conversations.count).not_to eq(0)
expect(Contact.all.first.name).to eq('Sojan Jose')
expect(Contact.all.first.name).to eq('Sojan')
expect(Contact.all.first.last_name).to eq('Jose')
expect(Contact.all.first.additional_attributes['social_telegram_user_id']).to eq(5_171_248)
expect(telegram_channel.inbox.messages.first.content).to eq('Option 1')
end
@@ -20,7 +20,8 @@ describe Whatsapp::IncomingMessageService do
it 'creates appropriate conversations, message and contacts' do
described_class.new(inbox: whatsapp_channel.inbox, params: params).perform
expect(whatsapp_channel.inbox.conversations.count).not_to eq(0)
expect(Contact.all.first.name).to eq('Sojan Jose')
expect(Contact.all.first.name).to eq('Sojan')
expect(Contact.all.first.last_name).to eq('Jose')
expect(whatsapp_channel.inbox.messages.first.content).to eq('Test')
end
@@ -178,7 +179,7 @@ describe Whatsapp::IncomingMessageService do
}.with_indifferent_access
described_class.new(inbox: whatsapp_channel.inbox, params: params).perform
expect(whatsapp_channel.inbox.conversations.count).not_to eq(0)
expect(Contact.all.first.name).to eq('Sojan Jose')
expect(Contact.all.first.name).to eq('Sojan')
expect(whatsapp_channel.inbox.messages.first.content).to eq('First Button')
end
end
@@ -196,7 +197,7 @@ describe Whatsapp::IncomingMessageService do
}.with_indifferent_access
described_class.new(inbox: whatsapp_channel.inbox, params: params).perform
expect(whatsapp_channel.inbox.conversations.count).not_to eq(0)
expect(Contact.all.first.name).to eq('Sojan Jose')
expect(Contact.all.first.name).to eq('Sojan')
expect(whatsapp_channel.inbox.messages.first.content).to eq('Yes this is a button')
end
end
@@ -219,7 +220,7 @@ describe Whatsapp::IncomingMessageService do
}.with_indifferent_access
described_class.new(inbox: whatsapp_channel.inbox, params: params).perform
expect(whatsapp_channel.inbox.conversations.count).not_to eq(0)
expect(Contact.all.first.name).to eq('Sojan Jose')
expect(Contact.all.first.name).to eq('Sojan')
expect(whatsapp_channel.inbox.messages.first.content).to eq('Check out my product!')
expect(whatsapp_channel.inbox.messages.first.attachments.present?).to be true
end
@@ -240,7 +241,7 @@ describe Whatsapp::IncomingMessageService do
}.with_indifferent_access
described_class.new(inbox: whatsapp_channel.inbox, params: params).perform
expect(whatsapp_channel.inbox.conversations.count).not_to eq(0)
expect(Contact.all.first.name).to eq('Sojan Jose')
expect(Contact.all.first.name).to eq('Sojan')
location_attachment = whatsapp_channel.inbox.messages.first.attachments.first
expect(location_attachment.file_type).to eq('location')
expect(location_attachment.fallback_title).to eq('Bay Bridge, San Francisco, CA, USA')
@@ -290,7 +291,8 @@ describe Whatsapp::IncomingMessageService do
it 'creates appropriate conversations, message and contacts if contact does not exit' do
described_class.new(inbox: whatsapp_channel.inbox, params: params).perform
expect(whatsapp_channel.inbox.conversations.count).not_to eq(0)
expect(Contact.all.first.name).to eq('Sojan Jose')
expect(Contact.all.first.name).to eq('Sojan')
expect(Contact.all.first.last_name).to eq('Jose')
expect(whatsapp_channel.inbox.messages.first.content).to eq('Test')
expect(whatsapp_channel.inbox.contact_inboxes.first.source_id).to eq(wa_id)
end
@@ -337,7 +339,7 @@ describe Whatsapp::IncomingMessageService do
it 'creates contact inbox with the incoming waid' do
described_class.new(inbox: whatsapp_channel.inbox, params: params).perform
expect(whatsapp_channel.inbox.conversations.count).not_to eq(0)
expect(Contact.all.first.name).to eq('Sojan Jose')
expect(Contact.all.first.name).to eq('Sojan')
expect(whatsapp_channel.inbox.messages.first.content).to eq('Test')
expect(whatsapp_channel.inbox.contact_inboxes.first.source_id).to eq(wa_id)
end
@@ -48,7 +48,8 @@ describe Whatsapp::IncomingMessageWhatsappCloudService do
described_class.new(inbox: whatsapp_channel.inbox, params: params).perform
expect(whatsapp_channel.inbox.conversations.count).not_to eq(0)
expect(Contact.all.first.name).to eq('Sojan Jose')
expect(Contact.all.first.name).to eq('Sojan')
expect(Contact.all.first.last_name).to eq('Jose')
expect(whatsapp_channel.inbox.messages.first.content).to eq('Check out my product!')
expect(whatsapp_channel.inbox.messages.first.attachments.present?).to be true
end
@@ -60,7 +61,7 @@ describe Whatsapp::IncomingMessageWhatsappCloudService do
described_class.new(inbox: whatsapp_channel.inbox, params: params).perform
expect(whatsapp_channel.inbox.conversations.count).not_to eq(0)
expect(Contact.all.first.name).to eq('Sojan Jose')
expect(Contact.all.first.name).to eq('Sojan')
expect(whatsapp_channel.inbox.messages.first.content).to eq('Check out my product!')
expect(whatsapp_channel.inbox.messages.first.attachments.present?).to be false
expect(whatsapp_channel.authorization_error_count).to eq(1)
@@ -100,7 +101,7 @@ describe Whatsapp::IncomingMessageWhatsappCloudService do
it 'with attachment errors' do
described_class.new(inbox: whatsapp_channel.inbox, params: error_params).perform
expect(whatsapp_channel.inbox.conversations.count).not_to eq(0)
expect(Contact.all.first.name).to eq('Sojan Jose')
expect(Contact.all.first.name).to eq('Sojan')
expect(whatsapp_channel.inbox.messages.count).to eq(0)
end
end