Class: Decidim::DownloadYourDataExportJob

Inherits:
ApplicationJob
  • Object
show all
Defined in:
decidim-core/app/jobs/decidim/download_your_data_export_job.rb

Instance Method Summary collapse

Instance Method Details

#perform(user, export_format = ::Decidim::DownloadYourDataExporter::DEFAULT_EXPORT_FORMAT) ⇒ Object



7
8
9
10
11
12
13
14
15
16
17
# File 'decidim-core/app/jobs/decidim/download_your_data_export_job.rb', line 7

def perform(user, export_format = ::Decidim::DownloadYourDataExporter::DEFAULT_EXPORT_FORMAT)
  filename = "#{SecureRandom.urlsafe_base64}.zip"
  path = Rails.root.join("tmp/#{filename}")
  password = SecureRandom.urlsafe_base64

  generate_zip_file(user, path, password, export_format)
  save_or_upload_file(user, path)
  # Deletes temporary file
  File.delete(path)
  ExportMailer.download_your_data_export(user, filename, password).deliver_later
end