docbrown/app/controllers/twilio_tokens_controller.rb
Michael Kohl 1729cf02ad
Move Twilio from labor to services (#11824)
* Move Twilio from labor to services

* Update usage
2020-12-10 10:21:09 +07:00

16 lines
698 B
Ruby

class TwilioTokensController < ApplicationController
after_action :verify_authorized
def show
video_channel = params[:id].split("private-video-channel-")[1] if params[:id].start_with?("private-video-channel-")
unless video_channel
skip_authorization
render json: { status: "failure", token: @twilio_token }, status: :not_found
return
end
@chat_channel = ChatChannel.find(video_channel.to_i)
authorize @chat_channel # show pundit method for chat_channel_policy works here, should always check though
@twilio_token = Twilio::GetJwtToken.call(current_user, params[:id])
render json: { status: "success", token: @twilio_token }, status: :ok
end
end