mirror of
https://github.com/lingble/chatwoot.git
synced 2025-10-29 18:22:53 +00:00
fix: Email collect overriding existing contact name (#7355)
Currently, if Enable email collect box is enabled, and the user starting the chat already has an account with the same email, it will override the current account with {name} from the email name@email.com , this fixes it.
Co-authored-by: Sojan <sojan@pepalo.com>
This commit is contained in:
@@ -17,7 +17,8 @@ class Api::V1::Widget::MessagesController < Api::V1::Widget::BaseController
|
||||
@message.update!(submitted_email: contact_email)
|
||||
ContactIdentifyAction.new(
|
||||
contact: @contact,
|
||||
params: { email: contact_email, name: contact_name }
|
||||
params: { email: contact_email, name: contact_name },
|
||||
retain_original_contact_name: true
|
||||
).perform
|
||||
else
|
||||
@message.update!(message_update_params[:message])
|
||||
|
||||
@@ -159,7 +159,7 @@ RSpec.describe '/api/v1/widget/messages', type: :request do
|
||||
it 'updates message in conversation and deletes the current contact' do
|
||||
message = create(:message, account: account, content_type: 'input_email', inbox: web_widget.inbox, conversation: conversation)
|
||||
email = Faker::Internet.email
|
||||
create(:contact, account: account, email: email)
|
||||
existing_contact = create(:contact, account: account, email: email, name: 'John Doe')
|
||||
contact_params = { email: email }
|
||||
put api_v1_widget_message_url(message.id),
|
||||
params: { website_token: web_widget.website_token, contact: contact_params },
|
||||
@@ -168,6 +168,7 @@ RSpec.describe '/api/v1/widget/messages', type: :request do
|
||||
|
||||
expect(response).to have_http_status(:success)
|
||||
message.reload
|
||||
expect(existing_contact.reload.name).to eq('John Doe')
|
||||
expect { contact.reload }.to raise_error(ActiveRecord::RecordNotFound)
|
||||
end
|
||||
|
||||
|
||||
Reference in New Issue
Block a user