Sha256: 9966c1c208ab3f96f24b432723c1814fc57d11c91b8ed681ae8c5c9184130eb0

Contents?: true

Size: 1.48 KB

Versions: 27

Compression:

Stored size: 1.48 KB

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.
    # export_name - The name of the export.
    # export_data - The data containing the result of the export.
    #
    # Returns nothing.
    def export(user, export_name, export_data)
      @user = user
      @organization = user.organization

      filename = export_data.filename(export_name)
      filename_without_extension = export_data.filename(export_name, extension: false)

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

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

    # Public: Sends a notification email with a link to retrieve
    # the result of a download_your_data export in a zipped file.
    #
    # user - The user to be notified.
    #
    # Returns nothing.
    def download_your_data_export(user, filename, password)
      @user = user
      @organization = user.organization
      @filename = filename
      @password = password

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

Version data entries

27 entries across 27 versions & 1 rubygems

Version Path
decidim-core-0.29.2 app/mailers/decidim/export_mailer.rb
decidim-core-0.28.5 app/mailers/decidim/export_mailer.rb
decidim-core-0.29.1 app/mailers/decidim/export_mailer.rb
decidim-core-0.28.4 app/mailers/decidim/export_mailer.rb
decidim-core-0.27.9 app/mailers/decidim/export_mailer.rb
decidim-core-0.29.0 app/mailers/decidim/export_mailer.rb
decidim-core-0.28.3 app/mailers/decidim/export_mailer.rb
decidim-core-0.27.8 app/mailers/decidim/export_mailer.rb
decidim-core-0.29.0.rc4 app/mailers/decidim/export_mailer.rb
decidim-core-0.29.0.rc3 app/mailers/decidim/export_mailer.rb
decidim-core-0.29.0.rc2 app/mailers/decidim/export_mailer.rb
decidim-core-0.29.0.rc1 app/mailers/decidim/export_mailer.rb
decidim-core-0.28.2 app/mailers/decidim/export_mailer.rb
decidim-core-0.27.7 app/mailers/decidim/export_mailer.rb
decidim-core-0.28.1 app/mailers/decidim/export_mailer.rb
decidim-core-0.27.6 app/mailers/decidim/export_mailer.rb
decidim-core-0.28.0 app/mailers/decidim/export_mailer.rb
decidim-core-0.27.5 app/mailers/decidim/export_mailer.rb
decidim-core-0.28.0.rc5 app/mailers/decidim/export_mailer.rb
decidim-core-0.28.0.rc4 app/mailers/decidim/export_mailer.rb