Sha256: ae136a366d4c341deadb2ba2fdc95cfa3e867df709e68cf088992f8f9e5cdecd

Contents?: true

Size: 735 Bytes

Versions: 7

Compression:

Stored size: 735 Bytes

Contents

class ExportMailer < ApplicationMailer
  def export_email(file_export)
    set_current_for_development
    expires_in = (file_export.expires_at - Time.now).to_i
    @model = file_export.associated_model_name&.pluralize
    @link = file_export.export_file.url(expires_in:)
    @expires_at = file_export.expires_at.utc
    mail(to: file_export&.exported_by&.email, subject: "#{@model} Export is ready for download")
  end

  private

  def set_current_for_development
    return unless Rails.env.development?

    url = Rails.application.credentials[:be_url]
    host = URI.parse(url).host
    protocol = URI.parse(url).scheme
    port = URI.parse(url).port
    ActiveStorage::Current.url_options = { host:, protocol:, port: }
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
cm-admin-4.4.8 app/mailers/export_mailer.rb
cm-admin-4.4.6 app/mailers/export_mailer.rb
cm-admin-4.4.1 app/mailers/export_mailer.rb
cm-admin-4.4.0 app/mailers/export_mailer.rb
cm-admin-4.3.0 app/mailers/export_mailer.rb
cm-admin-4.2.1 app/mailers/export_mailer.rb
cm-admin-4.2.0 app/mailers/export_mailer.rb