Class: ActionMailboxAmazonIngress::SnsNotification

Inherits:
Object
  • Object
show all
Defined in:
lib/action_mailbox_amazon_ingress/sns_notification.rb

Defined Under Namespace

Classes: MessageContentError

Instance Method Summary collapse

Constructor Details

#initialize(request_body) ⇒ SnsNotification

Returns a new instance of SnsNotification.



9
10
11
# File 'lib/action_mailbox_amazon_ingress/sns_notification.rb', line 9

def initialize(request_body)
  @request_body = request_body
end

Instance Method Details

#message_contentObject



29
30
31
32
33
34
35
36
37
38
39
# File 'lib/action_mailbox_amazon_ingress/sns_notification.rb', line 29

def message_content
  raise MessageContentError, 'Incoming emails must have notificationType `Received`' unless receipt?

  if content_in_s3?
    s3_content
  else
    return message[:content] unless destination

    "X-Original-To: #{destination}\n#{message[:content]}"
  end
end

#subscription_confirmed?Boolean

Returns:

  • (Boolean)


13
14
15
# File 'lib/action_mailbox_amazon_ingress/sns_notification.rb', line 13

def subscription_confirmed?
  confirmation_response.code&.start_with?('2')
end

#topicObject



21
22
23
# File 'lib/action_mailbox_amazon_ingress/sns_notification.rb', line 21

def topic
  notification.fetch(:TopicArn)
end

#typeObject



25
26
27
# File 'lib/action_mailbox_amazon_ingress/sns_notification.rb', line 25

def type
  notification.fetch(:Type)
end

#verified?Boolean

Returns:

  • (Boolean)


17
18
19
# File 'lib/action_mailbox_amazon_ingress/sns_notification.rb', line 17

def verified?
  Aws::SNS::MessageVerifier.new.authentic?(@request_body)
end