Files
chatwoot/app/mailers/portal_instructions_mailer.rb
Vishnu Narayanan 94829aea8d fix: footer in ssl_instructions email (#12076)
- 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"
/>
2025-07-31 11:44:17 -07:00

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