chore: Update widget config API to migrate the widget (#8303)

- Update the keys in the widget config API to support loading the widget separately from the Rails App.
This commit is contained in:
Pranav Raj S
2023-11-06 15:27:29 -08:00
committed by GitHub
parent b579ff832e
commit d1cbc56d67
2 changed files with 25 additions and 17 deletions

View File

@@ -1,29 +1,37 @@
json.chatwoot_website_channel do
json.website_channel_config do
json.allow_messages_after_resolved @web_widget.inbox.allow_messages_after_resolved
json.allow_reply_to @web_widget.inbox.account.feature_enabled?('message_reply_to')
json.api_host ENV.fetch('FRONTEND_URL', nil)
json.auth_token @token
json.avatar_url @web_widget.inbox.avatar_url
json.has_a_connected_agent_bot @web_widget.inbox.agent_bot&.name
json.csat_survey_enabled @web_widget.inbox.csat_survey_enabled
json.disable_branding @web_widget.inbox.account.feature_enabled?('disable_branding')
json.enabled_features @web_widget.selected_feature_flags
json.enabled_languages available_locales_with_name
json.locale @web_widget.account.locale
json.out_of_office_message @web_widget.inbox.out_of_office_message
json.portal @web_widget.inbox.portal
json.pre_chat_form_enabled @web_widget.pre_chat_form_enabled
json.pre_chat_form_options @web_widget.pre_chat_form_options
json.reply_time @web_widget.reply_time
json.timezone @web_widget.inbox.timezone
json.utc_off_set ActiveSupport::TimeZone[@web_widget.inbox.timezone].now.formatted_offset
json.website_name @web_widget.inbox.name
json.website_token @web_widget.website_token
json.welcome_tagline @web_widget.welcome_tagline
json.welcome_title @web_widget.welcome_title
json.widget_color @web_widget.widget_color
json.enabled_features @web_widget.selected_feature_flags
json.enabled_languages available_locales_with_name
json.reply_time @web_widget.reply_time
json.pre_chat_form_enabled @web_widget.pre_chat_form_enabled
json.pre_chat_form_options @web_widget.pre_chat_form_options
json.working_hours_enabled @web_widget.inbox.working_hours_enabled
json.csat_survey_enabled @web_widget.inbox.csat_survey_enabled
json.working_hours @web_widget.inbox.working_hours
json.out_of_office_message @web_widget.inbox.out_of_office_message
json.utc_off_set ActiveSupport::TimeZone[@web_widget.inbox.timezone].now.formatted_offset
end
# Remove the following defaults by June 2023 as it would be covered by the feature flags
json.chatwoot_widget_defaults do
json.use_inbox_avatar_for_bot @web_widget.use_inbox_avatar_for_bot
json.working_hours_enabled @web_widget.inbox.working_hours_enabled
end
json.contact do
json.email @contact.email
json.id @contact.id
json.identifier @contact.identifier
json.name @contact.name
json.phone_number @contact.phone_number
json.pubsub_token @contact_inbox.pubsub_token
end
json.auth_token @token
json.global_config @global_config

View File

@@ -10,7 +10,7 @@ RSpec.describe '/api/v1/widget/config', type: :request do
describe 'POST /api/v1/widget/config' do
let(:params) { { website_token: web_widget.website_token } }
let(:response_keys) { %w[chatwoot_website_channel chatwoot_widget_defaults contact auth_token global_config] }
let(:response_keys) { %w[website_channel_config contact global_config] }
context 'with invalid website token' do
it 'returns not found' do