forked from External/greenlight
initial commit
This commit is contained in:
41
app/controllers/application_controller.rb
Normal file
41
app/controllers/application_controller.rb
Normal file
@ -0,0 +1,41 @@
|
||||
require 'bigbluebutton_api'
|
||||
|
||||
class ApplicationController < ActionController::Base
|
||||
include SessionsHelper
|
||||
|
||||
protect_from_forgery with: :exception
|
||||
|
||||
MEETING_NAME_LIMIT = 90
|
||||
USER_NAME_LIMIT = 30
|
||||
|
||||
def meeting_name_limit
|
||||
MEETING_NAME_LIMIT
|
||||
end
|
||||
helper_method :meeting_name_limit
|
||||
|
||||
def user_name_limit
|
||||
USER_NAME_LIMIT
|
||||
end
|
||||
helper_method :user_name_limit
|
||||
|
||||
# Determines if the BigBlueButton endpoint is configured (or set to default).
|
||||
def bigbluebutton_endpoint_default?
|
||||
Rails.configuration.bigbluebutton_endpoint_default == Rails.configuration.bigbluebutton_endpoint
|
||||
end
|
||||
helper_method :bigbluebutton_endpoint_default?
|
||||
|
||||
private
|
||||
|
||||
# Ensure the user is logged into the room they are accessing.
|
||||
def verify_room_ownership
|
||||
return unless params.include?(:room_uid)
|
||||
@room = Room.find_by(uid: params[:room_uid])
|
||||
|
||||
# Redirect to correct room or root if not logged in.
|
||||
if current_user.nil?
|
||||
redirect_to root_path
|
||||
elsif @room.nil? || current_user != @room.user
|
||||
redirect_to room_path(current_user.room.uid)
|
||||
end
|
||||
end
|
||||
end
|
0
app/controllers/concerns/.keep
Normal file
0
app/controllers/concerns/.keep
Normal file
9
app/controllers/main_controller.rb
Normal file
9
app/controllers/main_controller.rb
Normal file
@ -0,0 +1,9 @@
|
||||
class MainController < ApplicationController
|
||||
|
||||
# GET /
|
||||
def index
|
||||
# If the user is logged in already, move them along to their room.
|
||||
redirect_to room_path(current_user.room.uid) if current_user
|
||||
end
|
||||
|
||||
end
|
82
app/controllers/meetings_controller.rb
Normal file
82
app/controllers/meetings_controller.rb
Normal file
@ -0,0 +1,82 @@
|
||||
class MeetingsController < ApplicationController
|
||||
|
||||
before_action :verify_room_ownership
|
||||
skip_before_action :verify_room_ownership, only: [:join, :wait]
|
||||
|
||||
# GET /rooms/:room_uid/meetings
|
||||
def index
|
||||
|
||||
end
|
||||
|
||||
# GET /rooms/:room_uid/meetings/:meeting_uid
|
||||
def show
|
||||
|
||||
end
|
||||
|
||||
# POST /rooms/:room_uid/meetings
|
||||
def create
|
||||
@meeting = Meeting.new(meeting_params(@room))
|
||||
|
||||
if @meeting.save
|
||||
# Create the meeting on the BigBlueButton server and join the user into the meeting.
|
||||
redirect_to join_meeting_path(room_uid: @room.uid, meeting_uid: @meeting.uid)
|
||||
else
|
||||
# Meeting couldn't be created, handle error.
|
||||
|
||||
end
|
||||
end
|
||||
|
||||
# GET /rooms/:room_uid/meetings/:meeting_uid/join
|
||||
def join
|
||||
@meeting = Meeting.find_by(uid: params[:meeting_uid])
|
||||
|
||||
if @meeting
|
||||
opts = default_meeting_options
|
||||
if @meeting.is_running?
|
||||
if current_user
|
||||
# Check if the current user is the room/session owner.
|
||||
opts[:user_is_moderator] = @meeting.room.owned_by?(current_user)
|
||||
redirect_to @meeting.join_path(current_user.name, opts)
|
||||
else
|
||||
# If the unauthenticated user has supplied a join name.
|
||||
if params[:join_name]
|
||||
redirect_to @meeting.join_path(params[:join_name], opts)
|
||||
else
|
||||
# Render the join page so they can supploy their name.
|
||||
render :join
|
||||
end
|
||||
end
|
||||
else
|
||||
# Only start the meeting if owner is joining first.
|
||||
if current_user && @meeting.room.owned_by?(current_user)
|
||||
opts[:user_is_moderator] = true
|
||||
redirect_to @meeting.join_path(current_user.name, opts)
|
||||
else
|
||||
# Send the user to a polling page that will auto join them when it starts.
|
||||
# The wait action/page handles input of name for unauthenticated users.
|
||||
render :wait
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
# GET /rooms/:room_uid/meetings/:meeting_uid/wait
|
||||
def wait
|
||||
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def meeting_params(room)
|
||||
params.require(:meeting).permit(:name).merge!(room_id: room.id)
|
||||
end
|
||||
|
||||
def default_meeting_options
|
||||
{
|
||||
user_is_moderator: false,
|
||||
meeting_logout_url: request.base_url + room_path(room_uid: @meeting.room.uid),
|
||||
moderator_message: "To invite someone to the meeting, send them this link:
|
||||
#{request.base_url + join_meeting_path(room_uid: @meeting.room.uid, meeting_uid: @meeting.uid)}"
|
||||
}
|
||||
end
|
||||
end
|
9
app/controllers/rooms_controller.rb
Normal file
9
app/controllers/rooms_controller.rb
Normal file
@ -0,0 +1,9 @@
|
||||
class RoomsController < ApplicationController
|
||||
|
||||
before_action :verify_room_ownership
|
||||
|
||||
# GET /rooms/:room_uid
|
||||
def index
|
||||
@meeting = Meeting.new
|
||||
end
|
||||
end
|
22
app/controllers/sessions_controller.rb
Normal file
22
app/controllers/sessions_controller.rb
Normal file
@ -0,0 +1,22 @@
|
||||
class SessionsController < ApplicationController
|
||||
|
||||
# GET /login
|
||||
def new
|
||||
end
|
||||
|
||||
# GET /logout
|
||||
def destroy
|
||||
logout
|
||||
end
|
||||
|
||||
# GET/POST /auth/:provider/callback
|
||||
def create
|
||||
user = User.from_omniauth(request.env['omniauth.auth'])
|
||||
login(user)
|
||||
end
|
||||
|
||||
# POST /auth/failure
|
||||
def fail
|
||||
|
||||
end
|
||||
end
|
Reference in New Issue
Block a user