Sha256: faa457b2f1bcf62f7b3c5fc8b3b13047bd37b8e1c1fd1cbbbac8e380535518ec

Contents?: true

Size: 936 Bytes

Versions: 11

Compression:

Stored size: 936 Bytes

Contents

# frozen_string_literal: true

module Decidim
  class DataPortabilityExportJob < ApplicationJob
    queue_as :default

    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(user, path)

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

    private

    def generate_zip_file(user, path, password, export_format)
      DataPortabilityExporter.new(user, path, password, export_format).export
    end

    # Saves to file system or uploads to storage service depending on the configuration.
    def save_or_upload_file(user, path)
      DataPortabilityUploader.new(user).store!(File.open(path, "rb"))
    end
  end
end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
decidim-core-0.24.3 app/jobs/decidim/data_portability_export_job.rb
decidim-core-0.23.6 app/jobs/decidim/data_portability_export_job.rb
decidim-core-0.24.2 app/jobs/decidim/data_portability_export_job.rb
decidim-core-0.23.5 app/jobs/decidim/data_portability_export_job.rb
decidim-core-0.24.1 app/jobs/decidim/data_portability_export_job.rb
decidim-core-0.24.0 app/jobs/decidim/data_portability_export_job.rb
decidim-core-0.24.0.rc2 app/jobs/decidim/data_portability_export_job.rb
decidim-core-0.23.4 app/jobs/decidim/data_portability_export_job.rb
decidim-core-0.24.0.rc1 app/jobs/decidim/data_portability_export_job.rb
decidim-core-0.23.3 app/jobs/decidim/data_portability_export_job.rb
decidim-core-0.23.2 app/jobs/decidim/data_portability_export_job.rb