greenlight/app/controllers/landing_controller.rb

83 lines
2.2 KiB
Ruby

# BigBlueButton open source conferencing system - http://www.bigbluebutton.org/.
#
# Copyright (c) 2016 BigBlueButton Inc. and by respective authors (see below).
#
# This program is free software; you can redistribute it and/or modify it under the
# terms of the GNU Lesser General Public License as published by the Free Software
# Foundation; either version 3.0 of the License, or (at your option) any later
# version.
#
# BigBlueButton is distributed in the hope that it will be useful, but WITHOUT ANY
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
# PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public License along
# with BigBlueButton; if not, see <http://www.gnu.org/licenses/>.
class LandingController < ApplicationController
include BbbApi
def index
end
def resource
if params[:id].size > meeting_name_limit
redirect_to action: :index
elsif params[:resource] == 'meetings' && !params[:room_id]
render_meeting
elsif params[:resource] == 'rooms'
render_room
else
redirect_to root_url, flash: {danger: "An error occured"}
end
end
def wait_for_moderator
render layout: false
end
def session_status_refresh
@user = User.find_by(encrypted_id: params[:room_id])
if @user.nil?
render head(:not_found) && return
end
@meeting_id = params[:id]
@meeting_running = bbb_get_meeting_info("#{@user.encrypted_id}-#{params[:id]}")[:returncode]
render layout: false
end
def admin?
@user && @user == current_user
end
helper_method :admin?
private
def render_meeting
@meeting_id = params[:id]
params[:action] = 'meetings'
render :action => 'meetings'
end
def render_room
params[:action] = 'rooms'
@user = User.find_by(encrypted_id: params[:room_id] || params[:id])
if @user.nil?
redirect_to root_path
return
end
if @user.encrypted_id != params[:id]
@meeting_id = params[:id]
end
@meeting_running = bbb_get_meeting_info("#{@user.encrypted_id}-#{@meeting_id}")[:returncode]
@main_room = @meeting_id.blank? || @meeting_id == @user.encrypted_id
render :action => 'rooms'
end
end