GRN-59: Implemented pagination on the API call (#370)

* Added the env variable and functionality to paginate the call to the bbbapi

* Update user.rb
This commit is contained in:
farhatahmad
2019-03-12 13:50:20 -04:00
committed by Jesus Federico
parent ab6655554c
commit 3195bb4429
12 changed files with 278 additions and 124 deletions

View File

@ -0,0 +1,55 @@
# frozen_string_literal: true
# BigBlueButton open source conferencing system - http://www.bigbluebutton.org/.
#
# Copyright (c) 2018 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 RecordingsController < ApplicationController
before_action :find_room
before_action :verify_room_ownership
META_LISTED = "gl-listed"
# POST /:meetingID/:record_id
def update_recording
meta = {
"meta_#{META_LISTED}" => (params[:state] == "public"),
}
res = @room.update_recording(params[:record_id], meta)
# Redirects to the page that made the initial request
redirect_to request.referrer if res[:updated]
end
# DELETE /:meetingID/:record_id
def delete_recording
@room.delete_recording(params[:record_id])
# Redirects to the page that made the initial request
redirect_to request.referrer
end
private
def find_room
@room = Room.find_by!(bbb_id: params[:meetingID])
end
# Ensure the user is logged into the room they are accessing.
def verify_room_ownership
redirect_to root_path unless @room.owned_by?(current_user)
end
end

View File

@ -17,6 +17,8 @@
# with BigBlueButton; if not, see <http://www.gnu.org/licenses/>.
class RoomsController < ApplicationController
include RecordingsHelper
before_action :validate_accepted_terms, unless: -> { !Rails.configuration.terms }
before_action :validate_verified_email, except: [:show, :join],
unless: -> { !Rails.configuration.enable_email_verification }
@ -24,9 +26,6 @@ class RoomsController < ApplicationController
before_action :verify_room_ownership, except: [:create, :show, :join, :logout]
before_action :verify_room_owner_verified, only: [:show, :join]
include RecordingsHelper
META_LISTED = "gl-listed"
# POST /
def create
redirect_to(root_path) && return unless current_user
@ -52,10 +51,7 @@ class RoomsController < ApplicationController
def show
if current_user && @room.owned_by?(current_user)
recs = @room.recordings
# Add the room id to each recording object
recs.each do |rec|
rec[:room_uid] = @room.uid
end
@recordings = recs
@is_running = @room.running?
else
@ -168,26 +164,6 @@ class RoomsController < ApplicationController
redirect_to @room
end
# POST /:room_uid/:record_id
def update_recording
meta = {
"meta_#{META_LISTED}" => (params[:state] == "public"),
}
res = @room.update_recording(params[:record_id], meta)
# Redirects to the page that made the initial request
redirect_to request.referrer if res[:updated]
end
# DELETE /:room_uid/:record_id
def delete_recording
@room.delete_recording(params[:record_id])
# Redirects to the page that made the initial request
redirect_to request.referrer
end
private
def update_room_attributes(update_type)

View File

@ -17,11 +17,11 @@
# with BigBlueButton; if not, see <http://www.gnu.org/licenses/>.
class UsersController < ApplicationController
include RecordingsHelper
before_action :find_user, only: [:edit, :update, :destroy]
before_action :ensure_unauthenticated, only: [:new, :create]
include RecordingsHelper
# POST /u
def create
# Verify that GreenLight is configured to allow user signup.
@ -135,19 +135,7 @@ class UsersController < ApplicationController
# GET /u/:user_uid/recordings
def recordings
if current_user && current_user.uid == params[:user_uid]
@recordings = []
current_user.rooms.each do |room|
# Check that current user is the room owner
next unless room.owner == current_user
recs = room.recordings
# Add the room id to each recording object
recs.each do |rec|
rec[:room_uid] = room.uid
end
# Adds an array to another array
@recordings.push(*recs)
end
@recordings = current_user.all_recordings
else
redirect_to root_path
end