From d4a9fd9147704c17a4c1bb05c339b034478364f6 Mon Sep 17 00:00:00 2001 From: jfederico Date: Tue, 18 Oct 2016 17:25:06 -0400 Subject: [PATCH] Cleaned up code --- app/controllers/bbb_controller.rb | 4 +--- app/controllers/landing_controller.rb | 1 + app/helpers/application_helper.rb | 13 ------------- app/helpers/bbb_helper.rb | 16 +++++++++++++++- 4 files changed, 17 insertions(+), 17 deletions(-) diff --git a/app/controllers/bbb_controller.rb b/app/controllers/bbb_controller.rb index 9c9ef648..926aa33c 100644 --- a/app/controllers/bbb_controller.rb +++ b/app/controllers/bbb_controller.rb @@ -1,16 +1,14 @@ class BbbController < ApplicationController - include BbbHelper # GET /join # GET /join.json def join - logger.info params.to_json if ( !params.has_key?(:id) ) render_response("missing_parameter", "meeting token was not included", :bad_request) elsif ( !params.has_key?(:name) ) render_response("missing_parameter", "user name was not included", :bad_request) else - bbb_join_url = bbb_join_url(params[:id], false, params[:name], false) + bbb_join_url = helpers.bbb_join_url(params[:id], false, params[:name], false) if bbb_join_url[:returncode] logger.info "#Execute the redirect" render_response("ok", "execute the redirect", :ok, {:join_url => bbb_join_url[:join_url]}) diff --git a/app/controllers/landing_controller.rb b/app/controllers/landing_controller.rb index 9129b250..6965767c 100644 --- a/app/controllers/landing_controller.rb +++ b/app/controllers/landing_controller.rb @@ -1,4 +1,5 @@ class LandingController < ApplicationController + def index @refreshable = (params[:resource] == 'meeting' && !params.has_key?(:id)) @meeting_token = params[:id] || @meeting_token = helpers.new_meeting_token diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 0a20de1d..de6be794 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -1,15 +1,2 @@ module ApplicationHelper - def bbb_endpoint - Rails.application.secrets[:bbb_endpoint] - end - - def bbb_secret - Rails.application.secrets[:bbb_secret] - end - - def random_password(length) - o = [('a'..'z'), ('A'..'Z')].map { |i| i.to_a }.flatten - password = (0...length).map { o[rand(o.length)] }.join - return password - end end diff --git a/app/helpers/bbb_helper.rb b/app/helpers/bbb_helper.rb index 9a3a6fc0..94901495 100644 --- a/app/helpers/bbb_helper.rb +++ b/app/helpers/bbb_helper.rb @@ -1,6 +1,20 @@ module BbbHelper + def bbb_endpoint + Rails.application.secrets[:bbb_endpoint] + end + + def bbb_secret + Rails.application.secrets[:bbb_secret] + end + + def random_password(length) + o = [('a'..'z'), ('A'..'Z')].map { |i| i.to_a }.flatten + password = (0...length).map { o[rand(o.length)] }.join + return password + end + def bbb_join_url(meeting_token, meeting_recorded=false, user_fullname='User', user_is_moderator=false) - bbb ||= BigBlueButton::BigBlueButtonApi.new(helpers.bbb_endpoint + "api", bbb_secret, "0.8", true) + bbb ||= BigBlueButton::BigBlueButtonApi.new(bbb_endpoint + "api", bbb_secret, "0.8", true) if !bbb return { :returncode => false, :messageKey => "BBBAPICallInvalid", :message => "BBB API call invalid." } else