Sha256: 0e1ac376a26c244402a4a177de088db8b9c897a216934e1a14722e398baa8841
Contents?: true
Size: 882 Bytes
Versions: 7
Compression:
Stored size: 882 Bytes
Contents
# frozen_string_literal: true module Decidim class DownloadYourDataExportJob < ApplicationJob queue_as :default 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) ExportMailer.download_your_data_export(user, filename, password).deliver_later end private def generate_zip_file(user, path, password, export_format) DownloadYourDataExporter.new(user, path, password, export_format).export end def save_or_upload_file(user, path) user.download_your_data_file.attach(io: File.open(path, "rb"), filename: File.basename(path)) end end end
Version data entries
7 entries across 7 versions & 1 rubygems