Sha256: fa7a588c6b1bea5fd901683d1122aff7f9965bd20d9031dac3d38cb0faf06044

Contents?: true

Size: 920 Bytes

Versions: 22

Compression:

Stored size: 920 Bytes

Contents

module Ddr
  module Events
    class VirusCheckEvent < Event

      include PreservationEventBehavior
      include ReindexObjectAfterSave

      self.preservation_event_type = :vir
      self.description = "Content file scanned for viruses"

      def to_solr
        { Ddr::IndexFields::LAST_VIRUS_CHECK_ON => event_date_time_s,
          Ddr::IndexFields::LAST_VIRUS_CHECK_OUTCOME => outcome }
      end

      # Message sent by ActiveSupport::Notifications
      def self.call(*args)
        notification = ActiveSupport::Notifications::Event.new(*args)
        result = notification.payload[:result] # Ddr::Antivirus::ScanResult instance
        create(pid: notification.payload[:pid],
               event_date_time: result.scanned_at,
               outcome: result.ok? ? SUCCESS : FAILURE,
               software: result.version,
               detail: result.to_s
               )
      end

    end
  end
end

Version data entries

22 entries across 22 versions & 1 rubygems

Version Path
ddr-models-1.14.1 lib/ddr/events/virus_check_event.rb
ddr-models-1.14.0 lib/ddr/events/virus_check_event.rb