forked from External/greenlight
Updated rubocop and fixed issues (#490)
This commit is contained in:
parent
bc57caa806
commit
a0c99dde47
1231
.rubocop.yml
1231
.rubocop.yml
File diff suppressed because it is too large
Load Diff
2
Gemfile
2
Gemfile
|
@ -76,7 +76,7 @@ group :production do
|
||||||
end
|
end
|
||||||
|
|
||||||
# Ruby linting.
|
# Ruby linting.
|
||||||
gem 'rubocop', '0.57.1'
|
gem 'rubocop'
|
||||||
|
|
||||||
group :development, :test do
|
group :development, :test do
|
||||||
# Call 'byebug' anywhere in the code to stop execution and get a debugger console
|
# Call 'byebug' anywhere in the code to stop execution and get a debugger console
|
||||||
|
|
10
Gemfile.lock
10
Gemfile.lock
|
@ -179,7 +179,6 @@ GEM
|
||||||
ast (~> 2.4.0)
|
ast (~> 2.4.0)
|
||||||
pg (0.21.0)
|
pg (0.21.0)
|
||||||
popper_js (1.14.5)
|
popper_js (1.14.5)
|
||||||
powerpack (0.1.2)
|
|
||||||
public_suffix (3.0.3)
|
public_suffix (3.0.3)
|
||||||
puma (3.11.4)
|
puma (3.11.4)
|
||||||
pyu-ruby-sasl (0.0.3.3)
|
pyu-ruby-sasl (0.0.3.3)
|
||||||
|
@ -244,14 +243,13 @@ GEM
|
||||||
rspec-mocks (~> 3.7.0)
|
rspec-mocks (~> 3.7.0)
|
||||||
rspec-support (~> 3.7.0)
|
rspec-support (~> 3.7.0)
|
||||||
rspec-support (3.7.1)
|
rspec-support (3.7.1)
|
||||||
rubocop (0.57.1)
|
rubocop (0.68.1)
|
||||||
jaro_winkler (~> 1.5.1)
|
jaro_winkler (~> 1.5.1)
|
||||||
parallel (~> 1.10)
|
parallel (~> 1.10)
|
||||||
parser (>= 2.5)
|
parser (>= 2.5, != 2.5.1.1)
|
||||||
powerpack (~> 0.1)
|
|
||||||
rainbow (>= 2.2.2, < 4.0)
|
rainbow (>= 2.2.2, < 4.0)
|
||||||
ruby-progressbar (~> 1.7)
|
ruby-progressbar (~> 1.7)
|
||||||
unicode-display_width (~> 1.0, >= 1.0.1)
|
unicode-display_width (>= 1.4.0, < 1.6)
|
||||||
ruby-progressbar (1.10.0)
|
ruby-progressbar (1.10.0)
|
||||||
rubyntlm (0.6.2)
|
rubyntlm (0.6.2)
|
||||||
safe_yaml (1.0.4)
|
safe_yaml (1.0.4)
|
||||||
|
@ -364,7 +362,7 @@ DEPENDENCIES
|
||||||
redis (~> 3.0)
|
redis (~> 3.0)
|
||||||
remote_syslog_logger
|
remote_syslog_logger
|
||||||
rspec-rails (~> 3.7)
|
rspec-rails (~> 3.7)
|
||||||
rubocop (= 0.57.1)
|
rubocop
|
||||||
sass-rails (~> 5.0)
|
sass-rails (~> 5.0)
|
||||||
shoulda-matchers (~> 3.1)
|
shoulda-matchers (~> 3.1)
|
||||||
spring
|
spring
|
||||||
|
|
|
@ -75,9 +75,7 @@ class PasswordResetsController < ApplicationController
|
||||||
|
|
||||||
# Checks expiration of reset token.
|
# Checks expiration of reset token.
|
||||||
def check_expiration
|
def check_expiration
|
||||||
if current_user.password_reset_expired?
|
redirect_to new_password_reset_url, alert: I18n.t("expired_reset_token") if current_user.password_reset_expired?
|
||||||
redirect_to new_password_reset_url, alert: I18n.t("expired_reset_token")
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def reset_link
|
def reset_link
|
||||||
|
|
|
@ -144,8 +144,8 @@ class RoomsController < ApplicationController
|
||||||
|
|
||||||
begin
|
begin
|
||||||
redirect_to @room.join_path(current_user.name, opts, current_user.uid)
|
redirect_to @room.join_path(current_user.name, opts, current_user.uid)
|
||||||
rescue BigBlueButton::BigBlueButtonException => exc
|
rescue BigBlueButton::BigBlueButtonException => e
|
||||||
redirect_to room_path, alert: I18n.t(exc.key.to_s.underscore, default: I18n.t("bigbluebutton_exception"))
|
redirect_to room_path, alert: I18n.t(e.key.to_s.underscore, default: I18n.t("bigbluebutton_exception"))
|
||||||
end
|
end
|
||||||
|
|
||||||
# Notify users that the room has started.
|
# Notify users that the room has started.
|
||||||
|
@ -192,7 +192,7 @@ class RoomsController < ApplicationController
|
||||||
|
|
||||||
def create_room_settings_string(mute_res, client_res)
|
def create_room_settings_string(mute_res, client_res)
|
||||||
room_settings = {}
|
room_settings = {}
|
||||||
room_settings["muteOnStart"] = mute_res == "1" ? true : false
|
room_settings["muteOnStart"] = mute_res == "1"
|
||||||
|
|
||||||
if client_res.eql? "html5"
|
if client_res.eql? "html5"
|
||||||
room_settings["joinViaHtml5"] = true
|
room_settings["joinViaHtml5"] = true
|
||||||
|
|
|
@ -84,8 +84,8 @@ module ApplicationHelper
|
||||||
begin
|
begin
|
||||||
provider_info = retrieve_provider_info(@user_domain, 'api2', 'getUserGreenlightCredentials')
|
provider_info = retrieve_provider_info(@user_domain, 'api2', 'getUserGreenlightCredentials')
|
||||||
provider_info['provider'] == 'greenlight'
|
provider_info['provider'] == 'greenlight'
|
||||||
rescue => ex
|
rescue => e
|
||||||
logger.info ex
|
logger.info e
|
||||||
false
|
false
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -31,7 +31,7 @@ module RecordingsHelper
|
||||||
len = valid_playbacks.first[:length]
|
len = valid_playbacks.first[:length]
|
||||||
if len > 60
|
if len > 60
|
||||||
"#{(len / 60).to_i} hrs #{len % 60} mins"
|
"#{(len / 60).to_i} hrs #{len % 60} mins"
|
||||||
elsif len == 0
|
elsif len.zero?
|
||||||
"< 1 min"
|
"< 1 min"
|
||||||
else
|
else
|
||||||
"#{len} min"
|
"#{len} min"
|
||||||
|
|
|
@ -60,22 +60,20 @@ module SessionsHelper
|
||||||
|
|
||||||
def generate_checksum(user_domain, redirect_url, secret)
|
def generate_checksum(user_domain, redirect_url, secret)
|
||||||
string = user_domain + redirect_url + secret
|
string = user_domain + redirect_url + secret
|
||||||
OpenSSL::Digest.digest('sha1', string).unpack("H*").first
|
OpenSSL::Digest.digest('sha1', string).unpack1("H*")
|
||||||
end
|
end
|
||||||
|
|
||||||
def parse_user_domain(hostname)
|
def parse_user_domain(hostname)
|
||||||
return hostname.split('.').first if Rails.configuration.url_host.empty?
|
return hostname.split('.').first if Rails.configuration.url_host.empty?
|
||||||
Rails.configuration.url_host.split(',').each do |url_host|
|
Rails.configuration.url_host.split(',').each do |url_host|
|
||||||
if hostname.include?(url_host)
|
return hostname.chomp(url_host).chomp('.') if hostname.include?(url_host)
|
||||||
return hostname.chomp(url_host).chomp('.')
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
''
|
''
|
||||||
end
|
end
|
||||||
|
|
||||||
def omniauth_options(env)
|
def omniauth_options(env)
|
||||||
gl_redirect_url = (Rails.env.production? ? "https" : env["rack.url_scheme"]) + "://" + env["SERVER_NAME"] + ":" +
|
gl_redirect_url = (Rails.env.production? ? "https" : env["rack.url_scheme"]) + "://" + env["SERVER_NAME"] + ":" +
|
||||||
env["SERVER_PORT"]
|
env["SERVER_PORT"]
|
||||||
user_domain = parse_user_domain(env["SERVER_NAME"])
|
user_domain = parse_user_domain(env["SERVER_NAME"])
|
||||||
env['omniauth.strategy'].options[:customer] = user_domain
|
env['omniauth.strategy'].options[:customer] = user_domain
|
||||||
env['omniauth.strategy'].options[:gl_redirect_url] = gl_redirect_url
|
env['omniauth.strategy'].options[:gl_redirect_url] = gl_redirect_url
|
||||||
|
|
|
@ -67,9 +67,9 @@ class Room < ApplicationRecord
|
||||||
unless meeting[:messageKey] == 'duplicateWarning'
|
unless meeting[:messageKey] == 'duplicateWarning'
|
||||||
update_attributes(sessions: sessions + 1, last_session: DateTime.now)
|
update_attributes(sessions: sessions + 1, last_session: DateTime.now)
|
||||||
end
|
end
|
||||||
rescue BigBlueButton::BigBlueButtonException => exc
|
rescue BigBlueButton::BigBlueButtonException => e
|
||||||
puts "BigBlueButton failed on create: #{exc.key}: #{exc.message}"
|
puts "BigBlueButton failed on create: #{e.key}: #{e.message}"
|
||||||
raise exc
|
raise e
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -225,7 +225,7 @@ class User < ApplicationRecord
|
||||||
|
|
||||||
# Initializes a room for the user and assign a BigBlueButton user id.
|
# Initializes a room for the user and assign a BigBlueButton user id.
|
||||||
def initialize_main_room
|
def initialize_main_room
|
||||||
self.uid = "gl-#{(0...12).map { (65 + rand(26)).chr }.join.downcase}"
|
self.uid = "gl-#{(0...12).map { rand(65..90).chr }.join.downcase}"
|
||||||
self.main_room = Room.create!(owner: self, name: I18n.t("home_room"))
|
self.main_room = Room.create!(owner: self, name: I18n.t("home_room"))
|
||||||
save
|
save
|
||||||
end
|
end
|
||||||
|
|
|
@ -101,6 +101,6 @@ module Greenlight
|
||||||
config.room_features = ENV['ROOM_FEATURES'] || ""
|
config.room_features = ENV['ROOM_FEATURES'] || ""
|
||||||
|
|
||||||
# The maximum number of rooms included in one bbbapi call
|
# The maximum number of rooms included in one bbbapi call
|
||||||
config.pagination_number = ENV['PAGINATION_NUMBER'].to_i == 0 ? 25 : ENV['PAGINATION_NUMBER'].to_i
|
config.pagination_number = ENV['PAGINATION_NUMBER'].to_i.zero? ? 25 : ENV['PAGINATION_NUMBER'].to_i
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -113,7 +113,5 @@ Rails.application.configure do
|
||||||
config.active_record.dump_schema_after_migration = false
|
config.active_record.dump_schema_after_migration = false
|
||||||
|
|
||||||
# Set the relative url root for deployment to a subdirectory.
|
# Set the relative url root for deployment to a subdirectory.
|
||||||
if ENV['RELATIVE_URL_ROOT'] != "/"
|
config.relative_url_root = ENV['RELATIVE_URL_ROOT'] || "/b" if ENV['RELATIVE_URL_ROOT'] != "/"
|
||||||
config.relative_url_root = ENV['RELATIVE_URL_ROOT'] || "/b"
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
|
@ -64,7 +64,7 @@ module BbbApi
|
||||||
def encode_bbb_url(base_url, secret, params, route = 'getUser')
|
def encode_bbb_url(base_url, secret, params, route = 'getUser')
|
||||||
encoded_params = params.to_param
|
encoded_params = params.to_param
|
||||||
string = route + encoded_params + secret
|
string = route + encoded_params + secret
|
||||||
checksum = OpenSSL::Digest.digest('sha1', string).unpack('H*').first
|
checksum = OpenSSL::Digest.digest('sha1', string).unpack1('H*')
|
||||||
|
|
||||||
URI.parse("#{base_url}#{route}?#{encoded_params}&checksum=#{checksum}")
|
URI.parse("#{base_url}#{route}?#{encoded_params}&checksum=#{checksum}")
|
||||||
end
|
end
|
||||||
|
|
|
@ -12,9 +12,7 @@ namespace :conf do
|
||||||
# Initial check that variables are set
|
# Initial check that variables are set
|
||||||
print "\nChecking environment"
|
print "\nChecking environment"
|
||||||
ENV_VARIABLES.each do |var|
|
ENV_VARIABLES.each do |var|
|
||||||
if ENV[var].blank?
|
failed("#{var} not set correctly") if ENV[var].blank?
|
||||||
failed("#{var} not set correctly")
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
passed
|
passed
|
||||||
|
|
||||||
|
@ -48,8 +46,8 @@ def test_smtp
|
||||||
ENV['SMTP_AUTH']) do |s|
|
ENV['SMTP_AUTH']) do |s|
|
||||||
s.sendmail('test', ENV['SMTP_USERNAME'], 'notifications@example.com')
|
s.sendmail('test', ENV['SMTP_USERNAME'], 'notifications@example.com')
|
||||||
end
|
end
|
||||||
rescue => exc
|
rescue => e
|
||||||
failed("Error connecting to SMTP - #{exc}")
|
failed("Error connecting to SMTP - #{e}")
|
||||||
end
|
end
|
||||||
|
|
||||||
# Takes the full URL including the protocol
|
# Takes the full URL including the protocol
|
||||||
|
@ -58,11 +56,9 @@ def test_request(url)
|
||||||
res = Net::HTTP.get(uri)
|
res = Net::HTTP.get(uri)
|
||||||
|
|
||||||
doc = Nokogiri::XML(res)
|
doc = Nokogiri::XML(res)
|
||||||
if doc.css("returncode").text != "SUCCESS"
|
failed("Could not get a valid response from BigBlueButton server - #{res}") if doc.css("returncode").text != "SUCCESS"
|
||||||
failed("Could not get a valid response from BigBlueButton server - #{res}")
|
rescue => e
|
||||||
end
|
failed("Error connecting to BigBlueButton server - #{e}")
|
||||||
rescue => exc
|
|
||||||
failed("Error connecting to BigBlueButton server - #{exc}")
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def failed(msg)
|
def failed(msg)
|
||||||
|
|
|
@ -102,7 +102,7 @@ describe Room, type: :model do
|
||||||
query = fullname + meeting_id + password
|
query = fullname + meeting_id + password
|
||||||
checksum_string = "join#{query + secret}"
|
checksum_string = "join#{query + secret}"
|
||||||
|
|
||||||
checksum = OpenSSL::Digest.digest('sha1', checksum_string).unpack("H*").first
|
checksum = OpenSSL::Digest.digest('sha1', checksum_string).unpack1("H*")
|
||||||
expect(@room.join_path("Example")).to eql("#{endpoint}join?#{query}&checksum=#{checksum}")
|
expect(@room.join_path("Example")).to eql("#{endpoint}join?#{query}&checksum=#{checksum}")
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue