Sha256: 715f4f4736e14ff93b1ea522315aa6ad90b0c3ee057937d814cfcff1cbf71555

Contents?: true

Size: 674 Bytes

Versions: 3

Compression:

Stored size: 674 Bytes

Contents

# frozen_string_literal: true

module Decidim
  module DecidimAwesome
    class DestroyPrivateDataJob < ApplicationJob
      queue_as :default

      # Destroys private data associated with the resource
      def perform(resource)
        extra_fields = Decidim::DecidimAwesome::ProposalExtraField.where(
          proposal: Decidim::Proposals::Proposal.where(component: resource)
        ).where("private_body_updated_at < ?", DecidimAwesome.private_data_expiration_time.ago)

        extra_fields.find_each do |extra_field|
          extra_field.update(private_body: nil)
        end

        Lock.new(resource.organization).release!(resource)
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
decidim-decidim_awesome-0.10.3 app/jobs/decidim/decidim_awesome/destroy_private_data_job.rb
decidim-decidim_awesome-0.11.2 app/jobs/decidim/decidim_awesome/destroy_private_data_job.rb
decidim-decidim_awesome-0.11.1 app/jobs/decidim/decidim_awesome/destroy_private_data_job.rb