fix: Identifier not persisted on customer created via Inbox API Channel (#5804)

- Fixes the identifier not being used to identify the contact, this results in having a new contact created every time the email or phone is not supplied.

Fixes: #5704
This commit is contained in:
CristianDuta 2022-11-08 01:02:45 +01:00 committed by GitHub
parent 526722dffa
commit 479d88a480
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 10 additions and 1 deletions

View file

@ -7,7 +7,7 @@ class Public::Api::V1::Inboxes::ContactsController < Public::Api::V1::InboxesCon
@contact_inbox = ::ContactInboxWithContactBuilder.new(
source_id: source_id,
inbox: @inbox_channel.inbox,
contact_attributes: permitted_params.except(:identifier, :identifier_hash)
contact_attributes: permitted_params.except(:identifier_hash)
).perform
end

View file

@ -15,6 +15,15 @@ RSpec.describe 'Public Inbox Contacts API', type: :request do
expect(data['source_id']).not_to be_nil
expect(data['pubsub_token']).not_to be_nil
end
it 'persists the identifier of the contact' do
identifier = 'contact-identifier'
post "/public/api/v1/inboxes/#{api_channel.identifier}/contacts", params: { identifier: identifier }
expect(response).to have_http_status(:success)
db_contact = api_channel.account.contacts.find_by(identifier: identifier)
expect(db_contact).not_to be_nil
end
end
describe 'GET /public/api/v1/inboxes/{identifier}/contact/{source_id}' do