demarches-normaliennes/app/jobs/virus_scanner_job.rb
Pierre de La Morinerie 54a4db1c47 config: flip config.active_storage.queues
ActiveStorage jobs are now moved to their own queue.

For consistency, we also move our own analysis jobs (VirusScannerJob)
on the same `:active_storage_analysis` queue.
2020-08-05 16:48:36 +02:00

14 lines
368 B
Ruby

class VirusScannerJob < ApplicationJob
queue_as :active_storage_analysis
discard_on ActiveRecord::RecordNotFound
def perform(blob)
metadata = extract_metadata_via_virus_scanner(blob)
blob.update!(metadata: blob.metadata.merge(metadata))
end
def extract_metadata_via_virus_scanner(blob)
ActiveStorage::VirusScanner.new(blob).metadata
end
end