Class: S3Antivirus::Notifier
- Inherits:
-
Object
- Object
- S3Antivirus::Notifier
- Includes:
- AwsServices, Conf
- Defined in:
- lib/s3_antivirus/notifier.rb
Instance Method Summary collapse
-
#initialize(s3_record) ⇒ Notifier
constructor
A new instance of Notifier.
- #notify(status:, action:) ⇒ Object
Methods included from Conf
Methods included from AwsServices
Constructor Details
#initialize(s3_record) ⇒ Notifier
Returns a new instance of Notifier.
6 7 8 9 |
# File 'lib/s3_antivirus/notifier.rb', line 6 def initialize(s3_record) @s3_record = s3_record @bucket, @key, @version = s3_record.bucket, s3_record.key, s3_record.version end |
Instance Method Details
#notify(status:, action:) ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/s3_antivirus/notifier.rb', line 11 def notify(status:, action:) data = { action: action, bucket: @bucket, key: @key, status: status, } data[:version] = @version if @version = data.inject({}) do |result, (k,v)| result.merge( k => { data_type: "String", string_value: v } ) end sns.publish( topic_arn: conf['topic'], message: "#{@s3_record.human_key} is #{status}, #{action} action executed", subject: "s3-antivirus s3://#{@bucket}", message_attributes: ) end |