Files
old-holivud2/app/controllers/zoom_notifications_controller.rb
2020-06-03 07:24:01 +02:00

48 lines
1.0 KiB
Ruby

class ZoomNotificationsController < ApplicationController
skip_before_action :require_login
skip_after_action :verify_authorized
skip_after_action :verify_policy_scoped
skip_before_action :verify_authenticity_token
before_action :authorize_zoom
before_action :set_zoom_meeting, only: :create
def create
case notification_event
when 'meeting.started'
@zoom_meeting.started!
when 'meeting.ended'
@zoom_meeting.ended!
else
Rails.logger.info notification_type
Rails.logger.info notification
end
head :ok
end
private
def notification_event
params.dig(:event)
end
def notification_meeting_id
params.dig(:payload, :object, :id)
end
def notification_host_id
params.dig(:payload, :object, :host_id)
end
def set_zoom_meeting
@zoom_meeting = ZoomMeeting.find_by!(api_meeting_id: notification_meeting_id)
end
def authorize_zoom
if request.headers['Authorization'] != ENV['ZOOM_VERIFICATION_TOKEN']
head :forbidden
end
end
end