forked from External/greenlight
		
	adhere to rubocop guidelines
This commit is contained in:
		@@ -1,3 +1,5 @@
 | 
			
		||||
# frozen_string_literal: true
 | 
			
		||||
 | 
			
		||||
require 'bigbluebutton_api'
 | 
			
		||||
 | 
			
		||||
class ApplicationController < ActionController::Base
 | 
			
		||||
@@ -43,18 +45,18 @@ class ApplicationController < ActionController::Base
 | 
			
		||||
 | 
			
		||||
  # Determines if a form field needs the is-invalid class.
 | 
			
		||||
  def form_is_invalid?(obj, key)
 | 
			
		||||
    'is-invalid' if !obj.errors.messages[key].empty?
 | 
			
		||||
    'is-invalid' unless obj.errors.messages[key].empty?
 | 
			
		||||
  end
 | 
			
		||||
  helper_method :form_is_invalid?
 | 
			
		||||
  
 | 
			
		||||
 | 
			
		||||
  # Default, unconfigured meeting options.
 | 
			
		||||
  def default_meeting_options
 | 
			
		||||
    invite_msg = "To invite someone to the meeting, send them this link:"
 | 
			
		||||
    {
 | 
			
		||||
      user_is_moderator: false,
 | 
			
		||||
      meeting_logout_url: request.base_url + logout_room_path(@room),
 | 
			
		||||
      meeting_recorded: true,
 | 
			
		||||
      moderator_message: "To invite someone to the meeting, send them this link:\n\n
 | 
			
		||||
        #{request.base_url + relative_root + room_path(@room)}"
 | 
			
		||||
      moderator_message: "#{invite_msg}\n\n #{request.base_url + relative_root + room_path(@room)}",
 | 
			
		||||
    }
 | 
			
		||||
  end
 | 
			
		||||
end
 | 
			
		||||
 
 | 
			
		||||
@@ -1,9 +1,10 @@
 | 
			
		||||
# frozen_string_literal: true
 | 
			
		||||
 | 
			
		||||
class ErrorsController < ApplicationController
 | 
			
		||||
  
 | 
			
		||||
  def not_found
 | 
			
		||||
    render status: 404
 | 
			
		||||
  end
 | 
			
		||||
  
 | 
			
		||||
 | 
			
		||||
  def unprocessable
 | 
			
		||||
    render status: 422
 | 
			
		||||
  end
 | 
			
		||||
 
 | 
			
		||||
@@ -1,6 +1,7 @@
 | 
			
		||||
class MainController < ApplicationController
 | 
			
		||||
# frozen_string_literal: true
 | 
			
		||||
 | 
			
		||||
  #before_action :redirect_to_room
 | 
			
		||||
class MainController < ApplicationController
 | 
			
		||||
  # before_action :redirect_to_room
 | 
			
		||||
 | 
			
		||||
  # GET /
 | 
			
		||||
  def index
 | 
			
		||||
 
 | 
			
		||||
@@ -1,5 +1,6 @@
 | 
			
		||||
class RoomsController < ApplicationController
 | 
			
		||||
# frozen_string_literal: true
 | 
			
		||||
 | 
			
		||||
class RoomsController < ApplicationController
 | 
			
		||||
  before_action :validate_accepted_terms, unless: -> { !Rails.configuration.terms }
 | 
			
		||||
  before_action :find_room, except: :create
 | 
			
		||||
  before_action :verify_room_ownership, except: [:create, :show, :join, :logout]
 | 
			
		||||
@@ -9,7 +10,7 @@ class RoomsController < ApplicationController
 | 
			
		||||
  # POST /
 | 
			
		||||
  def create
 | 
			
		||||
    redirect_to root_path unless current_user
 | 
			
		||||
    
 | 
			
		||||
 | 
			
		||||
    @room = Room.new(name: room_params[:name])
 | 
			
		||||
    @room.owner = current_user
 | 
			
		||||
 | 
			
		||||
@@ -19,9 +20,6 @@ class RoomsController < ApplicationController
 | 
			
		||||
      else
 | 
			
		||||
        redirect_to @room
 | 
			
		||||
      end
 | 
			
		||||
    else
 | 
			
		||||
      # Handle room didn't save.
 | 
			
		||||
 | 
			
		||||
    end
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
@@ -29,7 +27,7 @@ class RoomsController < ApplicationController
 | 
			
		||||
  def show
 | 
			
		||||
    if current_user && @room.owned_by?(current_user)
 | 
			
		||||
      @recordings = @room.recordings
 | 
			
		||||
      @is_running = @room.is_running?
 | 
			
		||||
      @is_running = @room.running?
 | 
			
		||||
    else
 | 
			
		||||
      render :join
 | 
			
		||||
    end
 | 
			
		||||
@@ -47,7 +45,7 @@ class RoomsController < ApplicationController
 | 
			
		||||
      return
 | 
			
		||||
    end
 | 
			
		||||
 | 
			
		||||
    if @room.is_running?
 | 
			
		||||
    if @room.running?
 | 
			
		||||
      if current_user
 | 
			
		||||
        redirect_to @room.join_path(current_user.name, opts, current_user.uid)
 | 
			
		||||
      else
 | 
			
		||||
@@ -92,13 +90,13 @@ class RoomsController < ApplicationController
 | 
			
		||||
    current_user.main_room = @room
 | 
			
		||||
    current_user.save
 | 
			
		||||
 | 
			
		||||
    redirect_to @room    
 | 
			
		||||
    redirect_to @room
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
  # POST /:room_uid/:record_id
 | 
			
		||||
  def update_recording
 | 
			
		||||
    meta = {
 | 
			
		||||
      "meta_#{META_LISTED}" => (params[:state] == "public")
 | 
			
		||||
      "meta_#{META_LISTED}" => (params[:state] == "public"),
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    res = @room.update_recording(params[:record_id], meta)
 | 
			
		||||
@@ -124,12 +122,10 @@ class RoomsController < ApplicationController
 | 
			
		||||
 | 
			
		||||
    if len > 60
 | 
			
		||||
      "#{len / 60} hrs"
 | 
			
		||||
    elsif len == 0
 | 
			
		||||
      "< 1 min"
 | 
			
		||||
    else
 | 
			
		||||
      if len == 0
 | 
			
		||||
        "< 1 min"
 | 
			
		||||
      else
 | 
			
		||||
        "#{len} min"
 | 
			
		||||
      end
 | 
			
		||||
      "#{len} min"
 | 
			
		||||
    end
 | 
			
		||||
  end
 | 
			
		||||
  helper_method :recording_length
 | 
			
		||||
@@ -147,7 +143,7 @@ class RoomsController < ApplicationController
 | 
			
		||||
 | 
			
		||||
  # Ensure the user is logged into the room they are accessing.
 | 
			
		||||
  def verify_room_ownership
 | 
			
		||||
    bring_to_room if !@room.owned_by?(current_user)
 | 
			
		||||
    bring_to_room unless @room.owned_by?(current_user)
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
  # Redirects a user to their room.
 | 
			
		||||
 
 | 
			
		||||
@@ -1,5 +1,6 @@
 | 
			
		||||
class SessionsController < ApplicationController
 | 
			
		||||
# frozen_string_literal: true
 | 
			
		||||
 | 
			
		||||
class SessionsController < ApplicationController
 | 
			
		||||
  # GET /users/login
 | 
			
		||||
  def new
 | 
			
		||||
  end
 | 
			
		||||
@@ -13,11 +14,8 @@ class SessionsController < ApplicationController
 | 
			
		||||
  # POST /users/login
 | 
			
		||||
  def create
 | 
			
		||||
    user = User.find_by(email: session_params[:email])
 | 
			
		||||
    if user && user.authenticate(session_params[:password])
 | 
			
		||||
    if user.&authenticate(session_params[:password])
 | 
			
		||||
      login(user)
 | 
			
		||||
    else
 | 
			
		||||
      # Login unsuccessful, display error message.
 | 
			
		||||
      
 | 
			
		||||
    end
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -1,5 +1,6 @@
 | 
			
		||||
class UsersController < ApplicationController
 | 
			
		||||
# frozen_string_literal: true
 | 
			
		||||
 | 
			
		||||
class UsersController < ApplicationController
 | 
			
		||||
  before_action :find_user, only: [:edit, :update]
 | 
			
		||||
  before_action :ensure_unauthenticated, only: [:new, :create]
 | 
			
		||||
 | 
			
		||||
@@ -12,7 +13,7 @@ class UsersController < ApplicationController
 | 
			
		||||
    @user.provider = "greenlight"
 | 
			
		||||
 | 
			
		||||
    if @user.save
 | 
			
		||||
     login(@user)
 | 
			
		||||
      login(@user)
 | 
			
		||||
    else
 | 
			
		||||
      # Handle error on user creation.
 | 
			
		||||
      render :new
 | 
			
		||||
@@ -61,16 +62,13 @@ class UsersController < ApplicationController
 | 
			
		||||
        redirect_to edit_user_path(@user), notice: "Information successfully updated."
 | 
			
		||||
      else
 | 
			
		||||
        # Append custom errors.
 | 
			
		||||
        errors.each do |k, v| @user.errors.add(k, v) end
 | 
			
		||||
        errors.each { |k, v| @user.errors.add(k, v) }
 | 
			
		||||
        render :edit
 | 
			
		||||
      end
 | 
			
		||||
    elsif @user.update_attributes(user_params)
 | 
			
		||||
      redirect_to edit_user_path(@user), notice: "Information successfully updated."
 | 
			
		||||
    else
 | 
			
		||||
      # Update the core user attributes.
 | 
			
		||||
      if @user.update_attributes(user_params)
 | 
			
		||||
        redirect_to edit_user_path(@user), notice: "Information successfully updated."
 | 
			
		||||
      else
 | 
			
		||||
        render :edit
 | 
			
		||||
      end
 | 
			
		||||
      render :edit
 | 
			
		||||
    end
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
@@ -83,7 +81,7 @@ class UsersController < ApplicationController
 | 
			
		||||
      redirect_to current_user.main_room
 | 
			
		||||
    end
 | 
			
		||||
  end
 | 
			
		||||
  
 | 
			
		||||
 | 
			
		||||
  private
 | 
			
		||||
 | 
			
		||||
  def find_user
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user