Updated rubocop and fixed issues (#490)

This commit is contained in:
farhatahmad
2019-05-02 15:44:00 -04:00
committed by Jesus Federico
parent bc57caa806
commit a0c99dde47
15 changed files with 122 additions and 1179 deletions

View File

@ -75,9 +75,7 @@ class PasswordResetsController < ApplicationController
# Checks expiration of reset token.
def check_expiration
if current_user.password_reset_expired?
redirect_to new_password_reset_url, alert: I18n.t("expired_reset_token")
end
redirect_to new_password_reset_url, alert: I18n.t("expired_reset_token") if current_user.password_reset_expired?
end
def reset_link

View File

@ -144,8 +144,8 @@ class RoomsController < ApplicationController
begin
redirect_to @room.join_path(current_user.name, opts, current_user.uid)
rescue BigBlueButton::BigBlueButtonException => exc
redirect_to room_path, alert: I18n.t(exc.key.to_s.underscore, default: I18n.t("bigbluebutton_exception"))
rescue BigBlueButton::BigBlueButtonException => e
redirect_to room_path, alert: I18n.t(e.key.to_s.underscore, default: I18n.t("bigbluebutton_exception"))
end
# Notify users that the room has started.
@ -192,7 +192,7 @@ class RoomsController < ApplicationController
def create_room_settings_string(mute_res, client_res)
room_settings = {}
room_settings["muteOnStart"] = mute_res == "1" ? true : false
room_settings["muteOnStart"] = mute_res == "1"
if client_res.eql? "html5"
room_settings["joinViaHtml5"] = true

View File

@ -84,8 +84,8 @@ module ApplicationHelper
begin
provider_info = retrieve_provider_info(@user_domain, 'api2', 'getUserGreenlightCredentials')
provider_info['provider'] == 'greenlight'
rescue => ex
logger.info ex
rescue => e
logger.info e
false
end
end

View File

@ -31,7 +31,7 @@ module RecordingsHelper
len = valid_playbacks.first[:length]
if len > 60
"#{(len / 60).to_i} hrs #{len % 60} mins"
elsif len == 0
elsif len.zero?
"< 1 min"
else
"#{len} min"

View File

@ -60,22 +60,20 @@ module SessionsHelper
def generate_checksum(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
def parse_user_domain(hostname)
return hostname.split('.').first if Rails.configuration.url_host.empty?
Rails.configuration.url_host.split(',').each do |url_host|
if hostname.include?(url_host)
return hostname.chomp(url_host).chomp('.')
end
return hostname.chomp(url_host).chomp('.') if hostname.include?(url_host)
end
''
end
def omniauth_options(env)
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"])
env['omniauth.strategy'].options[:customer] = user_domain
env['omniauth.strategy'].options[:gl_redirect_url] = gl_redirect_url

View File

@ -67,9 +67,9 @@ class Room < ApplicationRecord
unless meeting[:messageKey] == 'duplicateWarning'
update_attributes(sessions: sessions + 1, last_session: DateTime.now)
end
rescue BigBlueButton::BigBlueButtonException => exc
puts "BigBlueButton failed on create: #{exc.key}: #{exc.message}"
raise exc
rescue BigBlueButton::BigBlueButtonException => e
puts "BigBlueButton failed on create: #{e.key}: #{e.message}"
raise e
end
end

View File

@ -225,7 +225,7 @@ class User < ApplicationRecord
# Initializes a room for the user and assign a BigBlueButton user id.
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"))
save
end