Module: SnsHelper
- Defined in:
- app/helpers/sns_helper.rb
Instance Method Summary collapse
- #sns_data ⇒ Object
- #sns_duplicate_submission? ⇒ Boolean
- #sns_message ⇒ Object
- #sns_message_id ⇒ Object
- #sns_notification_id ⇒ Object
- #sns_set_as_received! ⇒ Object
-
#sns_topic ⇒ Object
topic, without all the ARN.
- #sns_type ⇒ Object
- #sns_verified? ⇒ Boolean
Instance Method Details
#sns_data ⇒ Object
24 25 26 |
# File 'app/helpers/sns_helper.rb', line 24 def sns_data @sns_data ||= ActiveSupport::JSON.decode(request.body).symbolize_keys! end |
#sns_duplicate_submission? ⇒ Boolean
36 37 38 |
# File 'app/helpers/sns_helper.rb', line 36 def sns_duplicate_submission? Rails.cache.read() end |
#sns_message ⇒ Object
7 8 9 |
# File 'app/helpers/sns_helper.rb', line 7 def @sns_message ||= ActiveSupport::JSON.decode(sns_data[:Message]).symbolize_keys! end |
#sns_message_id ⇒ Object
28 29 30 |
# File 'app/helpers/sns_helper.rb', line 28 def sns_data[:MessageId] end |
#sns_notification_id ⇒ Object
20 21 22 |
# File 'app/helpers/sns_helper.rb', line 20 def sns_notification_id request.headers['x-amz-sns-message-id'] end |
#sns_set_as_received! ⇒ Object
32 33 34 |
# File 'app/helpers/sns_helper.rb', line 32 def sns_set_as_received! Rails.cache.write(, true, expires_in: 2.minutes) end |
#sns_topic ⇒ Object
topic, without all the ARN
12 13 14 |
# File 'app/helpers/sns_helper.rb', line 12 def sns_topic sns_data[:TopicArn].match(/([^:]*)$/)[0] end |
#sns_type ⇒ Object
16 17 18 |
# File 'app/helpers/sns_helper.rb', line 16 def sns_type request.headers['x-amz-sns-message-type'] end |
#sns_verified? ⇒ Boolean
2 3 4 5 |
# File 'app/helpers/sns_helper.rb', line 2 def sns_verified? # TODO https://docs.aws.amazon.com/sns/latest/dg/SendMessageToHttp.verify.signature.html return true end |