Skip to content

Commit

Permalink
LTI-357: fix for making actioncable endpoint be dynamically configured (
Browse files Browse the repository at this point in the history
  • Loading branch information
jfederico authored Apr 22, 2024
1 parent 2807dfc commit 8b521b4
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 4 deletions.
11 changes: 11 additions & 0 deletions app/controllers/rooms_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ class RoomsController < ApplicationController
before_action :check_for_cancel, only: [:create, :update]
before_action :allow_iframe_requests
before_action :set_current_locale
before_action :set_action_cable, only: %i[launch]

after_action :broadcast_meeting, only: [:meeting_end]

# GET /rooms/1
Expand Down Expand Up @@ -492,4 +494,13 @@ def room_handler(launch_params, tenant)

Digest::SHA1.hexdigest(input)
end

def set_action_cable
relative_url_root = Rails.configuration.relative_url_root
relative_url_root = relative_url_root.chop if relative_url_root[-1] == '/'
config = ActionCable::Server::Configuration.new
config.cable = { url: "wss://#{request.host}#{relative_url_root}/rooms/cable" }

ActionCable::Server::Base.new(config: config)
end
end
4 changes: 1 addition & 3 deletions config/application.rb
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ class Application < Rails::Application
# Settings in config/environments/* take precedence over those specified here.
# Application configuration should go into files in config/initializers
# -- all .rb files in that directory are automatically loaded.
config.url_host = ENV['URL_HOST']

config.build_number = ENV['BUILD_NUMBER'] || 'v1'

Expand All @@ -56,8 +55,7 @@ class Application < Rails::Application
# Mount Action Cable outside main process or domain
relative_url_root = config.relative_url_root
relative_url_root = relative_url_root.chop if relative_url_root[-1] == '/'
config.action_cable.url = "wss://#{ENV['URL_HOST']}#{relative_url_root}/rooms/cable"
config.action_cable.mount_path = '/rooms/cable'
config.action_cable.mount_path = "#{relative_url_root}/rooms/cable"

# Settings for external services.
config.cache_enabled = ENV.fetch('CACHE_ENABLED', 'false').casecmp?('true')
Expand Down
2 changes: 1 addition & 1 deletion config/routes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
# with BigBlueButton; if not, see <http://www.gnu.org/licenses/>.

Rails.application.routes.draw do
mount ActionCable.server => Rails.configuration.action_cable.url
mount ActionCable.server => '/rooms/cable'

scope 'rooms' do
get '/health_check', to: 'health_check#show'
Expand Down

0 comments on commit 8b521b4

Please sign in to comment.