feat: Custom fields in pre-chat form (#4135)

Fixes: #2744
This commit is contained in:
Muhsin Keloth
2022-03-14 15:06:56 +05:30
committed by GitHub
parent 578414d788
commit e730804b48
16 changed files with 328 additions and 137 deletions

View File

@@ -49,7 +49,6 @@ class Api::V1::Accounts::InboxesController < Api::V1::Accounts::BaseController
return if permitted_params(channel_attributes)[:channel].blank?
validate_email_channel(channel_attributes) if @inbox.inbox_type == 'Email'
@inbox.channel.update!(permitted_params(channel_attributes)[:channel])
update_channel_feature_flags
end

View File

@@ -68,7 +68,7 @@ class Api::V1::Widget::BaseController < ApplicationController
mergee_contact: @contact
).perform
else
@contact.update!(email: email, name: contact_name)
@contact.update!(email: email, name: contact_name, phone_number: contact_phone_number)
end
end
@@ -80,6 +80,10 @@ class Api::V1::Widget::BaseController < ApplicationController
params[:contact][:name] || contact_email.split('@')[0]
end
def contact_phone_number
params[:contact][:phone_number]
end
def browser_params
{
browser_name: browser.name,

View File

@@ -51,6 +51,7 @@ class Api::V1::Widget::ConversationsController < Api::V1::Widget::BaseController
end
def permitted_params
params.permit(:id, :typing_status, :website_token, :email, contact: [:name, :email], message: [:content, :referer_url, :timestamp, :echo_id])
params.permit(:id, :typing_status, :website_token, :email, contact: [:name, :email, :phone_number],
message: [:content, :referer_url, :timestamp, :echo_id])
end
end