demarches-normaliennes/app/models/concerns/blob_titre_identite_watermark_concern.rb
2020-11-25 16:19:06 +01:00

23 lines
553 B
Ruby

module BlobTitreIdentiteWatermarkConcern
extend ActiveSupport::Concern
included do
after_update_commit :enqueue_watermark_job
end
private
def titre_identite?
attachments.find { |attachment| attachment.record.class.name == 'Champs::TitreIdentiteChamp' }
end
def watermarked?
metadata[:watermark]
end
def enqueue_watermark_job
if titre_identite? && !watermarked? && analyzed? && virus_scanner.done? && Flipper.enabled?(:titre_identite_watermark)
TitreIdentiteWatermarkJob.perform_later(self)
end
end
end