one meeting per room

This commit is contained in:
Josh
2018-05-14 14:28:18 -04:00
parent 0f8a4734b2
commit 1ddc3172eb
13 changed files with 126 additions and 149 deletions

View File

@ -39,9 +39,6 @@ class ApplicationController < ActionController::Base
# 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

View File

@ -1,102 +1,14 @@
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 supply 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.
redirect_to wait_meeting_path(room_uid: @meeting.room.uid, meeting_uid: @meeting.uid)
end
end
else
# Handle meeting doesn't exist.
end
end
# GET /rooms/:room_uid/meetings/:meeting_uid/wait
def wait
@meeting = Meeting.find_by(uid: params[:meeting_uid])
if @meeting
if @meeting.is_running?
if current_user
# If they are logged in and waiting, use their account name.
redirect_to @meeting.join_path(current_user.name, default_meeting_options)
elsif !params[:unauthenticated_join_name].blank?
# Otherwise, use the name they submitted on the wating page.
redirect_to @meeting.join_path(params[:unauthenticated_join_name], default_meeting_options)
end
end
else
# Handle meeting doesn't exist.
end
end
private
def meeting_params(room)
params.require(:meeting).permit(:name).merge!(room: 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),
meeting_recorded: true,
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
#def meeting_params(room)
# params.require(:meeting).permit(:name).merge!(room: room)
#end
end

View File

@ -1,9 +1,82 @@
class RoomsController < ApplicationController
before_action :verify_room_ownership
before_action :find_room, :verify_room_ownership
skip_before_action :verify_room_ownership, only: [:join, :wait]
# GET /rooms/:room_uid
def index
@meeting = Meeting.new
end
end
# GET /rooms/:room_uid/join
def join
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 supply their name.
render :join
end
end
else
# Only start the meeting if owner is joining first.
if current_user && @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.
redirect_to wait_room_path(room_uid: @room.uid)
end
end
else
# Handle room doesn't exist.
end
end
# GET /rooms/:room_uid/wait
def wait
if @room
if @meeting.is_running?
if current_user
# If they are logged in and waiting, use their account name.
redirect_to @meeting.join_path(current_user.name, default_meeting_options)
elsif !params[:unauthenticated_join_name].blank?
# Otherwise, use the name they submitted on the wating page.
redirect_to @meeting.join_path(params[:unauthenticated_join_name], default_meeting_options)
end
end
else
# Handle room doesn't exist.
end
end
private
# Find the room from the uid.
def find_room
@room = Room.find_by(uid: params[:room_uid])
@meeting = @room.meeting
end
# Default, unconfigured meeting options.
def default_meeting_options
{
user_is_moderator: false,
meeting_logout_url: request.base_url + room_path(room_uid: @room.uid),
meeting_recorded: true,
moderator_message: "To invite someone to the meeting, send them this link:
#{request.base_url + join_room_path(room_uid: @room.uid)}"
}
end
end