45 lines
1.6 KiB
Ruby
45 lines
1.6 KiB
Ruby
class ConferenceMeetingsController < ApplicationController
|
|
require 'microsoft_graph'
|
|
|
|
def show
|
|
authorize broadcast = Broadcast.find(params[:broadcast_id])
|
|
case broadcast.conference_option
|
|
when 'zoom'
|
|
redirect_to broadcast.zoom_meeting_url
|
|
when 'ms_teams'
|
|
if broadcast.conference_join_url.nil?
|
|
begin
|
|
graph_api = MicrosoftGraph.new(
|
|
current_user,
|
|
ENV['AZURE_CLIENT_ID'],
|
|
ENV['AZURE_CLIENT_SECRET'],
|
|
ENV['AZURE_TENANT_ID'],
|
|
ENV['AZURE_SCOPES']
|
|
)
|
|
|
|
subject = "#{broadcast.name} Online Meeting"
|
|
teams_meeting = graph_api.create_teams_meeting(subject)
|
|
join_url = teams_meeting['joinUrl']
|
|
|
|
if join_url.present?
|
|
broadcast.conference_join_url = join_url
|
|
broadcast.save
|
|
else
|
|
raise StandardError, 'Failed to read teams meeting join URL'
|
|
end
|
|
rescue ActionController::InvalidAuthenticityToken => e
|
|
Rails.logger.error(e.message)
|
|
redirect_to project_broadcast_url(broadcast.project, broadcast), alert: t('.alerts.not_authenticated')
|
|
return
|
|
rescue StandardError => e
|
|
Rails.logger.error(e.message)
|
|
redirect_to project_broadcast_url(broadcast.project, broadcast), alert: t('.alerts.failed_to_join')
|
|
return
|
|
end
|
|
end
|
|
redirect_to broadcast.conference_join_url
|
|
else
|
|
redirect_to project_broadcast_url(broadcast.project, broadcast), alert: t('.alerts.unknown_conference_option')
|
|
end
|
|
end
|
|
end |