Class: Decidim::ExportMailer

Inherits:
ApplicationMailer show all
Defined in:
decidim-core/app/mailers/decidim/export_mailer.rb

Overview

This mailer sends a notification email containing the export as an attachment.

Instance Method Summary collapse

Instance Method Details

#download_your_data_export(user, filename, password) ⇒ Object

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.



35
36
37
38
39
40
41
42
43
44
# File 'decidim-core/app/mailers/decidim/export_mailer.rb', line 35

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

#export(user, export_name, export_data) ⇒ Object

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.



15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'decidim-core/app/mailers/decidim/export_mailer.rb', line 15

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