Last active
May 4, 2017 05:39
-
-
Save randika/e42f7b719c58704e12c34d2b1121982b to your computer and use it in GitHub Desktop.
Revisions
-
randika renamed this gist
May 4, 2017 . 1 changed file with 0 additions and 0 deletions.There are no files selected for viewing
File renamed without changes. -
randika created this gist
May 4, 2017 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,66 @@ def sns_transcode_completed amz_message_type = request.headers['x-amz-sns-message-type'] amz_sns_topic = request.headers['x-amz-sns-topic-arn'] if !amz_sns_topic.nil? && amz_sns_topic.to_s.downcase == Settings.aws.transcode.sns_topic_arn request_body = JSON.parse(request.body.read, {:symbolize_names => true}) notification = Hashie::Mash.new(request_body) puts request_body.inspect if amz_message_type.to_s.downcase == 'subscriptionconfirmation' subscribe_url = request_body['SubscribeURL'] if !subscribe_url.to_s.empty? && !subscribe_url.nil? subscribe_confirm = HTTParty.get subscribe_url puts subscribe_confirm puts subscribe_url end end if amz_message_type.to_s.downcase == 'notification' puts "--------------------------" puts notification.inspect puts "--------------------------" puts notification.MessageId puts "--------------------------" puts notification.Message puts "--------------------------" puts "Result is #{notification.Message}" puts "--------------------------" parsed_message = JSON.parse(notification.Message, {:symbolize_names => true}) puts parsed_message.inspect puts "--------------------------" message = Message.where(transcode_job_id: parsed_message[:jobId]).first if message.present? # SET THE MESSAGE TO PUBLISHED STATE & TRIGGER SENDOUTS # BETTER CHECK THE THE AWS TRANSCODER JOB STATUS TOO message.update_attributes(state: Message::STATE_PUBLISHED) message.sendouts.update_all(state: Sendout::STATE_PUBLISHED) message.send_push_notifications end end end render :nothing => true, :status => 200, :content_type => 'text/html' end