mirror of
https://github.com/lingble/chatwoot.git
synced 2025-11-01 03:27:52 +00:00
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:
@@ -7,7 +7,7 @@ class Public::Api::V1::Inboxes::ContactsController < Public::Api::V1::InboxesCon
|
|||||||
@contact_inbox = ::ContactInboxWithContactBuilder.new(
|
@contact_inbox = ::ContactInboxWithContactBuilder.new(
|
||||||
source_id: source_id,
|
source_id: source_id,
|
||||||
inbox: @inbox_channel.inbox,
|
inbox: @inbox_channel.inbox,
|
||||||
contact_attributes: permitted_params.except(:identifier, :identifier_hash)
|
contact_attributes: permitted_params.except(:identifier_hash)
|
||||||
).perform
|
).perform
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -15,6 +15,15 @@ RSpec.describe 'Public Inbox Contacts API', type: :request do
|
|||||||
expect(data['source_id']).not_to be_nil
|
expect(data['source_id']).not_to be_nil
|
||||||
expect(data['pubsub_token']).not_to be_nil
|
expect(data['pubsub_token']).not_to be_nil
|
||||||
end
|
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
|
end
|
||||||
|
|
||||||
describe 'GET /public/api/v1/inboxes/{identifier}/contact/{source_id}' do
|
describe 'GET /public/api/v1/inboxes/{identifier}/contact/{source_id}' do
|
||||||
|
|||||||
Reference in New Issue
Block a user