2020-05-31 22:38:19 +02:00
|
|
|
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
|
2020-06-03 07:24:01 +02:00
|
|
|
Rails.logger.info notification_type
|
2020-05-31 22:38:19 +02:00
|
|
|
Rails.logger.info notification
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
head :ok
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
private
|
|
|
|
|
|
|
|
|
|
def notification_event
|
2020-06-03 07:24:01 +02:00
|
|
|
params.dig(:event)
|
2020-05-31 22:38:19 +02:00
|
|
|
end
|
|
|
|
|
|
|
|
|
|
def notification_meeting_id
|
2020-06-03 07:24:01 +02:00
|
|
|
params.dig(:payload, :object, :id)
|
2020-05-31 22:38:19 +02:00
|
|
|
end
|
|
|
|
|
|
|
|
|
|
def notification_host_id
|
2020-06-03 07:24:01 +02:00
|
|
|
params.dig(:payload, :object, :host_id)
|
2020-05-31 22:38:19 +02:00
|
|
|
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
|