Skip to content

Commit

Permalink
fix: normalize phone number in campaign message
Browse files Browse the repository at this point in the history
  • Loading branch information
clairton committed Aug 6, 2024
1 parent 3e9c6f7 commit cb3b00c
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions app/jobs/campaign_message_job.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
class CampaignMessageJob < ApplicationJob
include Whatsapp::IncomingMessageServiceHelpers
queue_as :low
retry_on ActiveRecord::RecordNotFound, wait: 30.seconds, attempts: 5

Expand Down Expand Up @@ -29,12 +30,16 @@ def bind(template, params)
end

def create_contact_inbox(inbox_id, params)
phone_number = params[:phone_number].delete('+').to_s
phone_number = brazil_phone_number?(phone_number) ? normalised_brazil_mobile_number(phone_number) : phone_number
phone_number = processed_waid(phone_number)

contact_inbox = ContactInboxWithContactBuilder.new(
source_id: params[:phone_number].delete('+').to_s,
source_id: phone_number,
inbox: Inbox.find(inbox_id),
contact_attributes: {
name: params[:name],
phone_number: params[:phone_number]
phone_number: "+#{phone_number}"
}
).perform
raise ActiveRecord::RecordNotFound if contact_inbox.nil?
Expand Down

0 comments on commit cb3b00c

Please sign in to comment.