allow selecting conference option
This commit is contained in:
@@ -18,25 +18,6 @@ class BroadcastsController < ApplicationController
|
|||||||
def create
|
def create
|
||||||
@broadcast.attributes = broadcast_params
|
@broadcast.attributes = broadcast_params
|
||||||
|
|
||||||
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']
|
|
||||||
@broadcast.microsoft_teams_meeting_url = join_url if join_url.present?
|
|
||||||
rescue StandardError => e
|
|
||||||
@broadcast.errors[:base] << e.message
|
|
||||||
render :new
|
|
||||||
return
|
|
||||||
end
|
|
||||||
|
|
||||||
if @broadcast.save
|
if @broadcast.save
|
||||||
log_create_analytics
|
log_create_analytics
|
||||||
redirect_to [@project, :broadcasts], notice: t(".notice")
|
redirect_to [@project, :broadcasts], notice: t(".notice")
|
||||||
@@ -46,8 +27,7 @@ class BroadcastsController < ApplicationController
|
|||||||
end
|
end
|
||||||
|
|
||||||
def show
|
def show
|
||||||
# @conference_url = url_for [@broadcast.project, @broadcast, :zoom_meeting]
|
@conference_url = url_for [@broadcast.project, @broadcast, :conference_meeting]
|
||||||
@conference_url = @broadcast.microsoft_teams_meeting_url
|
|
||||||
@recordings = @broadcast.broadcast_recordings.order_by_recent.paginate(page: params[:page])
|
@recordings = @broadcast.broadcast_recordings.order_by_recent.paginate(page: params[:page])
|
||||||
@files = @broadcast.files.order("created_at DESC").paginate(page: params[:files_page])
|
@files = @broadcast.files.order("created_at DESC").paginate(page: params[:files_page])
|
||||||
render layout: 'application'
|
render layout: 'application'
|
||||||
@@ -93,7 +73,7 @@ class BroadcastsController < ApplicationController
|
|||||||
end
|
end
|
||||||
|
|
||||||
def broadcast_params
|
def broadcast_params
|
||||||
params.require(:broadcast).permit(:name, :shoot_location_time_zone, files: [])
|
params.require(:broadcast).permit(:name, :shoot_location_time_zone, :conference_option, files: [])
|
||||||
end
|
end
|
||||||
|
|
||||||
def set_project
|
def set_project
|
||||||
|
|||||||
42
app/controllers/conference_meetings_controller.rb
Normal file
42
app/controllers/conference_meetings_controller.rb
Normal file
@@ -0,0 +1,42 @@
|
|||||||
|
class ConferenceMeetingsController < ApplicationController
|
||||||
|
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: 'You are not authenticated via Microsoft, please authenticate and try again'
|
||||||
|
return
|
||||||
|
rescue StandardError => e
|
||||||
|
Rails.logger.error(e.message)
|
||||||
|
redirect_to project_broadcast_url(broadcast.project, broadcast), alert: 'Failed to join conference'
|
||||||
|
return
|
||||||
|
end
|
||||||
|
end
|
||||||
|
redirect_to broadcast.conference_join_url
|
||||||
|
else
|
||||||
|
redirect_to project_broadcast_url(broadcast.project, broadcast), alert: 'Unknown conference option'
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
17
app/helpers/broadcast_conferences_helper.rb
Normal file
17
app/helpers/broadcast_conferences_helper.rb
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
module BroadcastConferencesHelper
|
||||||
|
def options_for_conference_select
|
||||||
|
[
|
||||||
|
['Zoom', 'zoom'],
|
||||||
|
['MS Teams', 'ms_teams']
|
||||||
|
]
|
||||||
|
end
|
||||||
|
|
||||||
|
def conference_option_name_from_key(key)
|
||||||
|
option = options_for_conference_select.find { |option| option[1] == key }
|
||||||
|
if option.present?
|
||||||
|
option.first
|
||||||
|
else
|
||||||
|
'Unknown conference option'
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
@@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
<%= bootstrap_form_with model: model, local: true do |form| %>
|
<%= bootstrap_form_with model: model, local: true do |form| %>
|
||||||
<%= form.text_field :name %>
|
<%= form.text_field :name %>
|
||||||
|
<%= form.select :conference_option, options_for_conference_select, { label: t('.labels.conference_option') }, class: "form-control custom-select" %>
|
||||||
<%= form.time_zone_select(:shoot_location_time_zone, nil, label: "Time zone of shoot location") %>
|
<%= form.time_zone_select(:shoot_location_time_zone, nil, label: "Time zone of shoot location") %>
|
||||||
|
|
||||||
<div class="row align-items-center text-center mt-4">
|
<div class="row align-items-center text-center mt-4">
|
||||||
|
|||||||
@@ -118,8 +118,8 @@
|
|||||||
</div>
|
</div>
|
||||||
<hr>
|
<hr>
|
||||||
<% end %>
|
<% end %>
|
||||||
<p class="card-text">If you want to join the ZOOM meeting dedicated to this broadcast, follow the link below.</p>
|
<p class="card-text"><%= "If you want to join the #{conference_option_name_from_key(@broadcast.conference_option)} meeting dedicated to this broadcast, follow the link below." %></p>
|
||||||
<%= link_to 'Video Conference', @conference_url, class: "btn btn-primary btn-block #{@conference_url.present? ? '' : 'disabled'}", target: '_blank' %>
|
<%= link_to 'Video Conference', @conference_url, class: "btn btn-primary btn-block", target: '_blank' %>
|
||||||
</div>
|
</div>
|
||||||
<div class="<%= class_string("tab-pane fade show", "active" => params[:active_tab] == 'recordings') %>" id="recordings">
|
<div class="<%= class_string("tab-pane fade show", "active" => params[:active_tab] == 'recordings') %>" id="recordings">
|
||||||
<div id="broadcast_recordings">
|
<div id="broadcast_recordings">
|
||||||
|
|||||||
@@ -262,6 +262,9 @@ en:
|
|||||||
stream_multiple_cameras: Stream multiple cameras at one time
|
stream_multiple_cameras: Stream multiple cameras at one time
|
||||||
update:
|
update:
|
||||||
reset_notice: The Share URL has been reset, and the previous URL will no longer work. Please click "Copy URL" and share it again with those who you want to have access to this live stream
|
reset_notice: The Share URL has been reset, and the previous URL will no longer work. Please click "Copy URL" and share it again with those who you want to have access to this live stream
|
||||||
|
form:
|
||||||
|
labels:
|
||||||
|
conference_option: Conference Option
|
||||||
bulk_taggings:
|
bulk_taggings:
|
||||||
new_bulk_tag_modal:
|
new_bulk_tag_modal:
|
||||||
submit: Add
|
submit: Add
|
||||||
|
|||||||
@@ -120,6 +120,9 @@ es:
|
|||||||
stream_multiple_cameras: Stream multiple cameras at one time
|
stream_multiple_cameras: Stream multiple cameras at one time
|
||||||
update:
|
update:
|
||||||
reset_notice: The Share URL has been reset, and the previous URL will no longer work. Please click "Copy URL" and share it again with those who you want to have access to this live stream
|
reset_notice: The Share URL has been reset, and the previous URL will no longer work. Please click "Copy URL" and share it again with those who you want to have access to this live stream
|
||||||
|
form:
|
||||||
|
labels:
|
||||||
|
conference_option: Conference Option (ES)
|
||||||
contract_templates:
|
contract_templates:
|
||||||
blank_contracts:
|
blank_contracts:
|
||||||
create:
|
create:
|
||||||
|
|||||||
@@ -101,7 +101,7 @@ Rails.application.routes.draw do
|
|||||||
member do
|
member do
|
||||||
delete :destroy_file
|
delete :destroy_file
|
||||||
end
|
end
|
||||||
# resource :zoom_meeting, only: [:show]
|
resource :conference_meeting, only: [:show]
|
||||||
end
|
end
|
||||||
resources :directories, except: [:index] do
|
resources :directories, except: [:index] do
|
||||||
member do
|
member do
|
||||||
|
|||||||
@@ -0,0 +1,6 @@
|
|||||||
|
class AddConferenceDetailsToBroadcasts < ActiveRecord::Migration[6.0]
|
||||||
|
def change
|
||||||
|
add_column :broadcasts, :conference_option, :string
|
||||||
|
add_column :broadcasts, :conference_join_url, :string
|
||||||
|
end
|
||||||
|
end
|
||||||
@@ -1,5 +0,0 @@
|
|||||||
class AddMicrosoftTeamsMeetingJoinUrlToBroadcasts < ActiveRecord::Migration[6.0]
|
|
||||||
def change
|
|
||||||
add_column :broadcasts, :microsoft_teams_meeting_url, :string
|
|
||||||
end
|
|
||||||
end
|
|
||||||
@@ -563,7 +563,8 @@ CREATE TABLE public.broadcasts (
|
|||||||
streamer_status integer DEFAULT 0,
|
streamer_status integer DEFAULT 0,
|
||||||
shoot_location_time_zone character varying DEFAULT 'UTC'::character varying,
|
shoot_location_time_zone character varying DEFAULT 'UTC'::character varying,
|
||||||
full_live_stream_playback_uid character varying,
|
full_live_stream_playback_uid character varying,
|
||||||
microsoft_teams_meeting_url character varying
|
conference_option character varying,
|
||||||
|
conference_join_url character varying
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -17,11 +17,21 @@ class MicrosoftGraph
|
|||||||
end
|
end
|
||||||
|
|
||||||
def create_teams_meeting(subject)
|
def create_teams_meeting(subject)
|
||||||
|
if @refresh_token.nil? || @token_expires_at.nil?
|
||||||
|
raise ActionController::InvalidAuthenticityToken, 'Missing refresh token / token expiration'
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
# Obtain new token if token is expired or will expire in less than 5 minutes
|
# Obtain new token if token is expired or will expire in less than 5 minutes
|
||||||
if 5.minutes.from_now.to_i > @token_expires_at.seconds
|
if 5.minutes.from_now.to_i > @token_expires_at.seconds
|
||||||
refresh_access_token
|
refresh_access_token
|
||||||
end
|
end
|
||||||
|
|
||||||
|
if @token.nil?
|
||||||
|
raise ActionController::InvalidAuthenticityToken, 'Missing access token'
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
response = HTTParty.post(
|
response = HTTParty.post(
|
||||||
"#{BASE_URL}/me/onlineMeetings",
|
"#{BASE_URL}/me/onlineMeetings",
|
||||||
body: {
|
body: {
|
||||||
|
|||||||
Reference in New Issue
Block a user