Class: MobileWorkflow::SnsNotificationsController

Inherits:
ActionController::API
  • Object
show all
Defined in:
app/controllers/mobile_workflow/sns_notifications_controller.rb

Instance Method Summary collapse

Instance Method Details

#createObject



10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'app/controllers/mobile_workflow/sns_notifications_controller.rb', line 10

def create
  Rails.logger.info("Message body: #{message_body}")

  case message_body['Type']
  when 'SubscriptionConfirmation'
    confirm_subscription ? (head :ok) : (head :bad_request)
  else
    AddAttachmentJob.perform_now(object, object_key, attribute_name)
    head :ok
  end
rescue NameError => e
  Rails.logger.warn "Error attaching object: #{e.message}"
rescue ActiveRecord::RecordNotFound
  head :not_found
end