diff --git a/config/application.rb b/config/application.rb index b09f714e..2b831302 100644 --- a/config/application.rb +++ b/config/application.rb @@ -52,8 +52,8 @@ module Greenlight config.bigbluebutton_secret_default = "8cd8ef52e8e101574e400365b55e11a6" # Use standalone BigBlueButton server. - config.bigbluebutton_endpoint = ENV["BIGBLUEBUTTON_ENDPOINT"] || config.bigbluebutton_endpoint_default - config.bigbluebutton_secret = ENV["BIGBLUEBUTTON_SECRET"] || config.bigbluebutton_secret_default + config.bigbluebutton_endpoint = ENV["BIGBLUEBUTTON_ENDPOINT"].present? ? ENV["BIGBLUEBUTTON_ENDPOINT"] : config.bigbluebutton_endpoint_default + config.bigbluebutton_secret = ENV["BIGBLUEBUTTON_SECRET"].present? ? ENV["BIGBLUEBUTTON_SECRET"] : config.bigbluebutton_secret_default # Fix endpoint format if required. config.bigbluebutton_endpoint += "/" unless config.bigbluebutton_endpoint.ends_with?('/') diff --git a/lib/tasks/configuration.rake b/lib/tasks/configuration.rake index 602f245c..9e720988 100644 --- a/lib/tasks/configuration.rake +++ b/lib/tasks/configuration.rake @@ -16,15 +16,17 @@ namespace :conf do end passed + endpoint = fix_endpoint_format(ENV['BIGBLUEBUTTON_ENDPOINT']) + # Tries to establish a connection to the BBB server from Greenlight print "Checking Connection" - test_request(ENV['BIGBLUEBUTTON_ENDPOINT']) + test_request(endpoint) passed # Tests the checksum on the getMeetings api call print "Checking Secret" checksum = Digest::SHA1.hexdigest("getMeetings#{ENV['BIGBLUEBUTTON_SECRET']}") - test_request("#{ENV['BIGBLUEBUTTON_ENDPOINT']}getMeetings?checksum=#{checksum}") + test_request("#{endpoint}getMeetings?checksum=#{checksum}") passed if ENV['ALLOW_MAIL_NOTIFICATIONS'] == 'true' @@ -61,6 +63,15 @@ rescue => e failed("Error connecting to BigBlueButton server - #{e}") end +def fix_endpoint_format(url) + # Fix endpoint format if required. + url += "/" unless url.ends_with?('/') + url += "api/" if url.ends_with?('bigbluebutton/') + url += "bigbluebutton/api/" unless url.ends_with?('bigbluebutton/api/') + + url +end + def failed(msg) print(": Failed\n#{msg}\n") exit