demarches-normaliennes/app/models/concerns/blob_titre_identite_watermark_concern.rb

24 lines
553 B
Ruby
Raw Normal View History

2020-11-17 16:34:24 +01:00
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)
2020-11-17 16:34:24 +01:00
TitreIdentiteWatermarkJob.perform_later(self)
end
end
end