Class: Chaskiq::HooksController

Inherits:
ApplicationController show all
Defined in:
app/controllers/chaskiq/hooks_controller.rb

Instance Method Summary collapse

Methods inherited from ApplicationController

#authentication_method, #get_referrer

Instance Method Details

#createObject



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'app/controllers/chaskiq/hooks_controller.rb', line 9

def create
  # get amazon message type and topic
  amz_message_type = request.headers['x-amz-sns-message-type']
  amz_sns_topic = request.headers['x-amz-sns-topic-arn']

  #return unless !amz_sns_topic.nil? &&
  #amz_sns_topic.to_s.downcase == 'arn:aws:sns:us-west-2:867544872691:User_Data_Updates'
  request_body = JSON.parse request.body.read

  # if this is the first time confirmation of subscription, then confirm it
  if amz_message_type.to_s.downcase == 'subscriptionconfirmation'
    send_subscription_confirmation request_body
    render text: "ok" and return
  end

  process_notification(request_body)
  render text: "ok" and return
end