mirror of
https://github.com/lingble/chatwoot.git
synced 2025-11-24 23:15:11 +00:00
- fix footer in helpcenter SSL instructions email ### before ---- <img width="676" height="398" alt="image" src="https://github.com/user-attachments/assets/f51376c8-0859-4005-b7f5-ca78926e54c8" /> ### after ---- <img width="778" height="418" alt="image" src="https://github.com/user-attachments/assets/92347ccc-80bc-4a7e-bc8c-0c1a8f69341b" />
42 lines
1.0 KiB
Ruby
42 lines
1.0 KiB
Ruby
class PortalInstructionsMailer < ApplicationMailer
|
|
def send_cname_instructions(portal:, recipient_email:)
|
|
return unless smtp_config_set_or_development?
|
|
return if target_domain.blank?
|
|
|
|
@portal = portal
|
|
@cname_record = generate_cname_record
|
|
|
|
send_mail_with_liquid(
|
|
to: recipient_email,
|
|
subject: I18n.t('portals.send_instructions.subject', custom_domain: @portal.custom_domain)
|
|
)
|
|
end
|
|
|
|
private
|
|
|
|
def liquid_locals
|
|
super.merge({ cname_record: @cname_record })
|
|
end
|
|
|
|
def generate_cname_record
|
|
"#{@portal.custom_domain} CNAME #{target_domain}"
|
|
end
|
|
|
|
def target_domain
|
|
helpcenter_url = ENV.fetch('HELPCENTER_URL', '')
|
|
frontend_url = ENV.fetch('FRONTEND_URL', '')
|
|
|
|
return extract_hostname(helpcenter_url) if helpcenter_url.present?
|
|
return extract_hostname(frontend_url) if frontend_url.present?
|
|
|
|
''
|
|
end
|
|
|
|
def extract_hostname(url)
|
|
uri = URI.parse(url)
|
|
uri.host
|
|
rescue URI::InvalidURIError
|
|
url.gsub(%r{https?://}, '').split('/').first
|
|
end
|
|
end
|