Class: Decidim::DataPortabilityExportJob

Inherits:
ApplicationJob
  • Object
show all
Defined in:
app/jobs/decidim/data_portability_export_job.rb

Instance Method Summary collapse

Instance Method Details

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



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

def perform(user, export_format = ::Decidim::DataPortabilityExporter::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(path)

  ExportMailer.data_portability_export(user, filename, password).deliver_later
end