chore: Improve Helpcenter custom domains (#5456)

- Support rendering articles over frontend URL
- Support rendering articles over help center URL
- Support rendering help center home page in the custom domain root
This commit is contained in:
Sojan Jose
2022-09-20 06:06:01 +05:30
committed by GitHub
parent a773ad7d08
commit 99de8f4500
10 changed files with 35 additions and 23 deletions

View File

@@ -4,7 +4,7 @@ class DashboardController < ActionController::Base
before_action :set_global_config
around_action :switch_locale
before_action :ensure_installation_onboarding, only: [:index]
before_action :redirect_to_custom_domain_page
before_action :render_hc_if_custom_domain, only: [:index]
layout 'vueapp'
@@ -38,13 +38,14 @@ class DashboardController < ActionController::Base
redirect_to '/installation/onboarding' if ::Redis::Alfred.get(::Redis::Alfred::CHATWOOT_INSTALLATION_ONBOARDING)
end
def redirect_to_custom_domain_page
custom_domain = request.host
portal = Portal.find_by(custom_domain: custom_domain)
def render_hc_if_custom_domain
domain = request.host
return if domain == URI.parse(ENV.fetch('FRONTEND_URL', '')).host
return unless portal
@portal = Portal.find_by(custom_domain: domain)
return unless @portal
redirect_to "/hc/#{portal.slug}"
render 'public/api/v1/portals/show', layout: 'portal', portal: @portal and return
end
def app_config