Sha256: f47ff1fc1506154d3e443c7c011af67294694662c27373148c75fdd940908ad2

Contents?: true

Size: 908 Bytes

Versions: 13

Compression:

Stored size: 908 Bytes

Contents

# frozen_string_literal: true

module Decidim
  # This mailer sends a notification email containing the export as an
  # attachment.
  class ExportMailer < ApplicationMailer
    # Public: Sends a notification email with the result of an export in a
    # zipped file.
    #
    # user        - The user to be notified.
    # name        - The name of the export.
    # export_data - The data containing the result of the export.
    #
    # Returns nothing.
    def export(user, name, export_data)
      @user = user
      @organization = user.organization

      original_file_name = "#{name}.#{export_data.extension}"

      attachments["#{name}.zip"] = FileZipper.new(
        original_file_name, export_data.read
      ).zip

      with_user(user) do
        mail(to: "#{user.name} <#{user.email}>", subject: I18n.t("decidim.export_mailer.subject", name: original_file_name))
      end
    end
  end
end

Version data entries

13 entries across 13 versions & 2 rubygems

Version Path
decidim-core-0.5.1 app/mailers/decidim/export_mailer.rb
decidim-0.5.1 decidim-core/app/mailers/decidim/export_mailer.rb
decidim-core-0.5.0 app/mailers/decidim/export_mailer.rb
decidim-0.5.0 decidim-core/app/mailers/decidim/export_mailer.rb
decidim-core-0.4.4 app/mailers/decidim/export_mailer.rb
decidim-core-0.4.2 app/mailers/decidim/export_mailer.rb
decidim-core-0.4.1 app/mailers/decidim/export_mailer.rb
decidim-core-0.4.3 app/mailers/decidim/export_mailer.rb
decidim-core-0.4.0 app/mailers/decidim/export_mailer.rb
decidim-core-0.3.2 app/mailers/decidim/export_mailer.rb
decidim-core-0.3.1 app/mailers/decidim/export_mailer.rb
decidim-core-0.3.0 app/mailers/decidim/export_mailer.rb
decidim-core-0.2.0 app/mailers/decidim/export_mailer.rb