Class: Msg::BouncesController
- Inherits:
-
ApplicationController
- Object
- ApplicationController
- Msg::BouncesController
- Defined in:
- app/controllers/msg/bounces_controller.rb
Instance Method Summary collapse
-
#create ⇒ Object
When the subscription is first set up they will also POST us a SubscriptionConfirmation, upon which we have to GET the given url to confirm that we are able to follow orders.
Instance Method Details
#create ⇒ Object
When the subscription is first set up they will also POST us a SubscriptionConfirmation, upon which we have to GET the given url to confirm that we are able to follow orders.
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'app/controllers/msg/bounces_controller.rb', line 10 def create if request.env['x-amz-sns-message-type'] == 'SubscriptionConfirmation' || ENV['HTTP_X_AMZ_SNS_MESSAGE_TYPE'] == "SubscriptionConfirmation" || @data['Type'] == "SubscriptionConfirmation" response = HTTParty.get(@data['SubscribeURL']) head :ok else mail_data = @data['mail'] bounce_data = @data['bounce'] recipients = [bounce_data['bouncedRecipients']].flatten envelope = Msg::Envelope.find_by_email_id(mail_data['messageId']) recipients.each do |recipient_data| Msg::Bounce.create({ :envelope => envelope, :bounce_type => bounce_data['bounceType'], :bounce_subtype => bounce_data['bounceSubType'], :reporter => bounce_data['reportingMTA'], :email => recipient_data['emailAddress'], :status => recipient_data['status'], :diagnostic => recipient_data['diagnosticCode'], :raw_message => JSON.dump(bounce_data) }) end head :ok end end |