forked from External/greenlight
		
	better error handling for youtube uploading
This commit is contained in:
		@@ -310,19 +310,24 @@ class @Recordings
 | 
				
			|||||||
        method: 'POST',
 | 
					        method: 'POST',
 | 
				
			||||||
        url: url+'/'+id
 | 
					        url: url+'/'+id
 | 
				
			||||||
        data: {video_title: title, privacy_status: privacy_status}
 | 
					        data: {video_title: title, privacy_status: privacy_status}
 | 
				
			||||||
        success: () ->
 | 
					        success: (data) ->
 | 
				
			||||||
          cloud = selectedUpload.find('.cloud-blue')
 | 
					 | 
				
			||||||
          check = selectedUpload.find('.green-check')
 | 
					 | 
				
			||||||
          spinner = selectedUpload.find('.load-spinner')
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
          showAlert(I18n.successful_upload, 4000);
 | 
					          if data['url'] != null
 | 
				
			||||||
 | 
					            window.location.href = data['url']
 | 
				
			||||||
 | 
					          else
 | 
				
			||||||
 | 
					            cloud = selectedUpload.find('.cloud-blue')
 | 
				
			||||||
 | 
					            check = selectedUpload.find('.green-check')
 | 
				
			||||||
 | 
					            spinner = selectedUpload.find('.load-spinner')
 | 
				
			||||||
 | 
					
 | 
				
			||||||
          spinner.hide()
 | 
					            showAlert(I18n.successful_upload, 4000);
 | 
				
			||||||
          check.show()
 | 
					
 | 
				
			||||||
          setTimeout ( ->
 | 
					            spinner.hide()
 | 
				
			||||||
            cloud.show()
 | 
					            check.show()
 | 
				
			||||||
            check.hide()
 | 
					
 | 
				
			||||||
          ), 2500
 | 
					            setTimeout ( ->
 | 
				
			||||||
 | 
					              cloud.show()
 | 
				
			||||||
 | 
					              check.hide()
 | 
				
			||||||
 | 
					            ), 2500
 | 
				
			||||||
      })
 | 
					      })
 | 
				
			||||||
 | 
					
 | 
				
			||||||
      selectedUpload.find('.cloud-blue').hide()
 | 
					      selectedUpload.find('.cloud-blue').hide()
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -180,10 +180,22 @@ class BbbController < ApplicationController
 | 
				
			|||||||
              title: params[:video_title],
 | 
					              title: params[:video_title],
 | 
				
			||||||
              description: t('youtube_description', url: 'https://bigbluebutton.org/'),
 | 
					              description: t('youtube_description', url: 'https://bigbluebutton.org/'),
 | 
				
			||||||
              privacy_status: params[:privacy_status])
 | 
					              privacy_status: params[:privacy_status])
 | 
				
			||||||
    rescue
 | 
					    rescue => e
 | 
				
			||||||
      # In this case, they don't have a youtube channel connected to their account, so prompt to create one.
 | 
					      errors = e.response_body['error']['errors']
 | 
				
			||||||
      redirect_to 'https://m.youtube.com/create_channel'
 | 
					      # Many complications, start by getting them to refresh their token.
 | 
				
			||||||
 | 
					      if errors.length > 1
 | 
				
			||||||
 | 
					        redirect_url = user_login_url
 | 
				
			||||||
 | 
					      else
 | 
				
			||||||
 | 
					        error = errors[0]
 | 
				
			||||||
 | 
					        if error['message'] == "Unauthorized"
 | 
				
			||||||
 | 
					          redirect_url = 'https://m.youtube.com/create_channel'
 | 
				
			||||||
 | 
					        else
 | 
				
			||||||
 | 
					          # In this case, they don't have a youtube channel connected to their account, so prompt to create one.
 | 
				
			||||||
 | 
					          redirect_url = user_login_url
 | 
				
			||||||
 | 
					        end
 | 
				
			||||||
 | 
					      end
 | 
				
			||||||
    end
 | 
					    end
 | 
				
			||||||
 | 
					    render json: {:url => redirect_url}
 | 
				
			||||||
  end
 | 
					  end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  # POST /rooms/:room_id/recordings/can_upload
 | 
					  # POST /rooms/:room_id/recordings/can_upload
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user