forked from External/greenlight
restructure app
This commit is contained in:
@ -47,9 +47,9 @@ class ApplicationController < ActionController::Base
|
||||
def default_meeting_options
|
||||
{
|
||||
user_is_moderator: false,
|
||||
meeting_logout_url: request.base_url + logout_room_path(@room.uid),
|
||||
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 + room_path(@room.uid)}"
|
||||
moderator_message: "To invite someone to the meeting, send them this link:\n\n#{request.base_url + room_path(@room)}"
|
||||
}
|
||||
end
|
||||
end
|
||||
|
@ -4,7 +4,6 @@ class MainController < ApplicationController
|
||||
|
||||
# GET /
|
||||
def index
|
||||
@meeting = Meeting.new
|
||||
end
|
||||
|
||||
private
|
||||
|
@ -1,46 +0,0 @@
|
||||
class MeetingsController < ApplicationController
|
||||
|
||||
# GET /m/:meeting_uid
|
||||
def show
|
||||
@meeting = Meeting.find_by(uid: params[:meeting_uid])
|
||||
if @meeting
|
||||
|
||||
else
|
||||
# Handle meeting doesn't exist.
|
||||
|
||||
end
|
||||
end
|
||||
|
||||
# POST /m/:meeting_uid
|
||||
def join
|
||||
meeting = Meeting.find_by(uid: params[:meeting_uid])
|
||||
if meeting
|
||||
# If the user is logged in, join using their authenticated name.
|
||||
if current_user
|
||||
redirect_to meeting.join_path(current_user.name)
|
||||
# Otherwise, use their inputed join name.
|
||||
elsif params[:join_name]
|
||||
redirect_to meeting.join_path(params[:join_name])
|
||||
end
|
||||
else
|
||||
# Handle meeting doesn't exist.
|
||||
|
||||
end
|
||||
end
|
||||
|
||||
# POST /m
|
||||
def create
|
||||
meeting = Meeting.new(meeting_params)
|
||||
if meeting.save
|
||||
redirect_to meeting_path(meeting_uid: meeting.uid)
|
||||
else
|
||||
redirect_to root_path
|
||||
end
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def meeting_params
|
||||
params.require(:meeting).permit(:name)
|
||||
end
|
||||
end
|
@ -1,27 +1,46 @@
|
||||
class RoomsController < ApplicationController
|
||||
|
||||
before_action :find_room, :verify_room_ownership
|
||||
skip_before_action :verify_room_ownership, only: [:show, :join, :wait]
|
||||
before_action :find_room, except: :create
|
||||
|
||||
# GET /r/:room_uid
|
||||
#before_action :verify_room_ownership
|
||||
#skip_before_action :verify_room_ownership, only: [:create, :show, :join, :wait]
|
||||
|
||||
# POST /r
|
||||
def create
|
||||
room = Room.new(name: room_params[:name])
|
||||
room.user = current_user
|
||||
|
||||
if room.save
|
||||
redirect_to room
|
||||
else
|
||||
|
||||
end
|
||||
end
|
||||
|
||||
# GET/POST /r/:room_uid
|
||||
def show
|
||||
opts = default_meeting_options
|
||||
|
||||
if @meeting.is_running?
|
||||
if @room.is_running?
|
||||
if current_user
|
||||
# If you don't own the room but the meeting is running, join up.
|
||||
if !@room.owned_by?(current_user)
|
||||
opts[:user_is_moderator] = false
|
||||
redirect_to @meeting.join_path(current_user.name, opts)
|
||||
redirect_to @room.join_path(current_user, opts)
|
||||
end
|
||||
else
|
||||
# If you're unauthenticated, you must enter a name to join the meeting.
|
||||
redirect_to join_room_path(@room.uid)
|
||||
if params[:join_name]
|
||||
redirect_to @room.join_path(params[:join_name], opts)
|
||||
else
|
||||
# Render the join page so they can supply their name.
|
||||
render :join
|
||||
end
|
||||
end
|
||||
else
|
||||
# If the meeting isn't running and you don't own the room, go to the waiting page.
|
||||
if !@room.owned_by?(current_user)
|
||||
redirect_to wait_room_path(@room.uid)
|
||||
redirect_to wait_room_path(@room)
|
||||
end
|
||||
end
|
||||
end
|
||||
@ -31,47 +50,19 @@ class RoomsController < ApplicationController
|
||||
# Join the user in and start the meeting.
|
||||
opts = default_meeting_options
|
||||
opts[:user_is_moderator] = true
|
||||
redirect_to @meeting.join_path(current_user.name, opts)
|
||||
end
|
||||
|
||||
# GET /r/:room_uid/join
|
||||
def join
|
||||
if @meeting.is_running?
|
||||
opts = default_meeting_options
|
||||
|
||||
if current_user
|
||||
# If the user exists, join them in.
|
||||
opts[:user_is_moderator] = @room.owned_by?(current_user)
|
||||
redirect_to @meeting.join_path(current_user.name, opts)
|
||||
else
|
||||
# If they are unauthenticated, prompt for 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
|
||||
if @room.owned_by?(current_user)
|
||||
# Redirect owner to room.
|
||||
redirect_to room_path(@room.uid)
|
||||
else
|
||||
# Otherwise, they have to wait for the meeting to start.
|
||||
redirect_to wait_room_path(@room.uid)
|
||||
end
|
||||
end
|
||||
redirect_to @room.join_path(current_user, opts)
|
||||
end
|
||||
|
||||
# GET/POST /r/:room_uid/wait
|
||||
def wait
|
||||
if @meeting.is_running?
|
||||
if @room.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)
|
||||
redirect_to @room.join_path(current_user, 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)
|
||||
redirect_to @room.join_path(params[:unauthenticated_join_name], default_meeting_options)
|
||||
end
|
||||
end
|
||||
end
|
||||
@ -79,7 +70,7 @@ class RoomsController < ApplicationController
|
||||
# GET /r/:room_uid/logout
|
||||
def logout
|
||||
# Redirect the owner to their room.
|
||||
redirect_to room_path(@room.uid)
|
||||
redirect_to root_path
|
||||
end
|
||||
|
||||
# GET /r/:room_uid/sessions
|
||||
@ -89,6 +80,10 @@ class RoomsController < ApplicationController
|
||||
|
||||
private
|
||||
|
||||
def room_params
|
||||
params.require(:room).permit(:name, :auto_join)
|
||||
end
|
||||
|
||||
# Find the room from the uid.
|
||||
def find_room
|
||||
@room = Room.find_by(uid: params[:room_uid])
|
||||
@ -97,8 +92,6 @@ class RoomsController < ApplicationController
|
||||
# Handle room doesn't exist.
|
||||
|
||||
end
|
||||
|
||||
@meeting = @room.meeting
|
||||
end
|
||||
|
||||
# Ensure the user is logged into the room they are accessing.
|
||||
|
Reference in New Issue
Block a user