diff --git a/web/app/assets/javascripts/jam_rest.js b/web/app/assets/javascripts/jam_rest.js index 26a6fbfdf..99c357923 100644 --- a/web/app/assets/javascripts/jam_rest.js +++ b/web/app/assets/javascripts/jam_rest.js @@ -2933,7 +2933,14 @@ }) } - + function getVideoConferencingRoomUrl(musicSessionId){ + return $.ajax({ + type: 'GET', + url: "/video/room/" + musicSessionId, + dataType: 'json', + contentType: 'application/json', + }) + } function initialize() { return self; @@ -3196,6 +3203,7 @@ this.changeSubscription = changeSubscription; this.cancelSubscription= cancelSubscription; this.listInvoices = listInvoices; + this.getVideoConferencingRoomUrl = getVideoConferencingRoomUrl; return this; }; })(window, jQuery); diff --git a/web/app/assets/javascripts/react-components/SessionVideoBtn.js.jsx.coffee b/web/app/assets/javascripts/react-components/SessionVideoBtn.js.jsx.coffee index 84efd2df1..f030ce4e5 100644 --- a/web/app/assets/javascripts/react-components/SessionVideoBtn.js.jsx.coffee +++ b/web/app/assets/javascripts/react-components/SessionVideoBtn.js.jsx.coffee @@ -1,5 +1,6 @@ context = window SessionActions = @SessionActions +rest = context.JK.Rest() @SessionVideoBtn = React.createClass({ @@ -22,8 +23,8 @@ SessionActions = @SessionActions return 'noclose' openBrowserToNewVideoServer: () -> - context.JK.popExternalLink("/video/room/#{context.SessionStore.id()}") - + rest.getVideoConferencingRoomUrl(context.SessionStore.id()).done((response) => context.JK.popExternalLink(response.url)) + sessionWebCam: (e) -> e.preventDefault(); diff --git a/web/app/controllers/music_sessions_controller.rb b/web/app/controllers/music_sessions_controller.rb index 66a223ef0..5e4446868 100644 --- a/web/app/controllers/music_sessions_controller.rb +++ b/web/app/controllers/music_sessions_controller.rb @@ -57,6 +57,6 @@ class MusicSessionsController < ApplicationController music_session = current_user.music_sessions.find(params[:music_session_id]) tok = current_user.temp_tokens.create video_conf_url = "#{Rails.application.config.video_conferencing_host}/room/#{music_session.id}?token=#{tok.token}" - redirect_to video_conf_url + render json: { url: video_conf_url } end end diff --git a/web/spec/controllers/music_sessions_controller_spec.rb b/web/spec/controllers/music_sessions_controller_spec.rb index bfc124955..4550abafc 100644 --- a/web/spec/controllers/music_sessions_controller_spec.rb +++ b/web/spec/controllers/music_sessions_controller_spec.rb @@ -20,21 +20,17 @@ describe MusicSessionsController, type: :controller do connection.connect! end - describe "video redirect" do + describe "video conferencing server url" do it "GET /video/room/:music_session_id" do get :session_video, music_session_id: music_session.id temp_token = TempToken.order(created_at: :desc).first expect(temp_token.user).to eq(user) video_conf_url = "#{Rails.application.config.video_conferencing_host}/room/#{music_session.id}?token=#{temp_token.token}" - response.should redirect_to video_conf_url - end - - it "GET /video/room/:music_session_id" do - get :session_video, music_session_id: music_session.id - temp_token = TempToken.order(created_at: :desc).first - expect(temp_token.user).to eq(user) - video_conf_url = "#{Rails.application.config.video_conferencing_host}/room/#{music_session.id}?token=#{temp_token.token}" - response.should redirect_to video_conf_url + #response.should redirect_to video_conf_url + resp = { + url: video_conf_url + } + response.body.should == resp.to_json end end end