2019-08-14 09:48:44 +00:00
|
|
|
class DashboardController < ActionController::Base
|
2021-01-08 20:13:17 +00:00
|
|
|
include SwitchLocale
|
|
|
|
|
2020-05-12 07:15:28 +00:00
|
|
|
before_action :set_global_config
|
2021-01-08 20:13:17 +00:00
|
|
|
around_action :switch_locale
|
2021-01-17 08:37:18 +00:00
|
|
|
before_action :ensure_installation_onboarding, only: [:index]
|
2022-09-20 00:36:01 +00:00
|
|
|
before_action :render_hc_if_custom_domain, only: [:index]
|
2021-01-08 20:13:17 +00:00
|
|
|
|
2019-08-14 09:48:44 +00:00
|
|
|
layout 'vueapp'
|
|
|
|
|
2019-10-20 08:47:26 +00:00
|
|
|
def index; end
|
2020-05-12 07:15:28 +00:00
|
|
|
|
|
|
|
private
|
|
|
|
|
|
|
|
def set_global_config
|
|
|
|
@global_config = GlobalConfig.get(
|
2022-07-19 13:34:17 +00:00
|
|
|
'LOGO', 'LOGO_THUMBNAIL',
|
2020-05-12 07:15:28 +00:00
|
|
|
'INSTALLATION_NAME',
|
|
|
|
'WIDGET_BRAND_URL',
|
|
|
|
'TERMS_URL',
|
|
|
|
'PRIVACY_URL',
|
2020-07-26 07:24:50 +00:00
|
|
|
'DISPLAY_MANIFEST',
|
2021-02-08 11:08:35 +00:00
|
|
|
'CREATE_NEW_ACCOUNT_FROM_DASHBOARD',
|
2021-06-07 18:52:36 +00:00
|
|
|
'CHATWOOT_INBOX_TOKEN',
|
|
|
|
'API_CHANNEL_NAME',
|
2021-09-07 17:41:01 +00:00
|
|
|
'API_CHANNEL_THUMBNAIL',
|
|
|
|
'ANALYTICS_TOKEN',
|
2022-02-15 10:46:54 +00:00
|
|
|
'ANALYTICS_HOST',
|
2022-02-18 14:32:50 +00:00
|
|
|
'DIRECT_UPLOADS_ENABLED',
|
2022-02-25 11:06:36 +00:00
|
|
|
'HCAPTCHA_SITE_KEY',
|
|
|
|
'LOGOUT_REDIRECT_LINK',
|
2022-07-19 13:34:17 +00:00
|
|
|
'DISABLE_USER_PROFILE_UPDATE',
|
|
|
|
'DEPLOYMENT_ENV'
|
2021-11-24 19:25:26 +00:00
|
|
|
).merge(app_config)
|
2020-05-12 07:15:28 +00:00
|
|
|
end
|
2021-01-17 08:37:18 +00:00
|
|
|
|
|
|
|
def ensure_installation_onboarding
|
|
|
|
redirect_to '/installation/onboarding' if ::Redis::Alfred.get(::Redis::Alfred::CHATWOOT_INSTALLATION_ONBOARDING)
|
|
|
|
end
|
2021-11-24 19:25:26 +00:00
|
|
|
|
2022-09-20 00:36:01 +00:00
|
|
|
def render_hc_if_custom_domain
|
|
|
|
domain = request.host
|
|
|
|
return if domain == URI.parse(ENV.fetch('FRONTEND_URL', '')).host
|
2022-09-07 06:52:24 +00:00
|
|
|
|
2022-09-20 00:36:01 +00:00
|
|
|
@portal = Portal.find_by(custom_domain: domain)
|
|
|
|
return unless @portal
|
2022-09-07 06:52:24 +00:00
|
|
|
|
2022-09-20 00:36:01 +00:00
|
|
|
render 'public/api/v1/portals/show', layout: 'portal', portal: @portal and return
|
2022-09-07 06:52:24 +00:00
|
|
|
end
|
|
|
|
|
2021-11-24 19:25:26 +00:00
|
|
|
def app_config
|
2022-05-10 13:50:55 +00:00
|
|
|
{
|
|
|
|
APP_VERSION: Chatwoot.config[:version],
|
2021-11-24 19:25:26 +00:00
|
|
|
VAPID_PUBLIC_KEY: VapidService.public_key,
|
|
|
|
ENABLE_ACCOUNT_SIGNUP: GlobalConfigService.load('ENABLE_ACCOUNT_SIGNUP', 'false'),
|
2022-05-10 13:50:55 +00:00
|
|
|
FB_APP_ID: GlobalConfigService.load('FB_APP_ID', ''),
|
2022-06-13 14:48:38 +00:00
|
|
|
FACEBOOK_API_VERSION: 'v14.0',
|
|
|
|
IS_ENTERPRISE: ChatwootApp.enterprise?
|
2022-05-10 13:50:55 +00:00
|
|
|
}
|
2021-11-24 19:25:26 +00:00
|
|
|
end
|
2019-10-20 08:47:26 +00:00
|
|
|
end
|