This repository has been archived on 2021-10-24. You can view files and clone it, but cannot push or open issues or pull requests.
greenlight/app/controllers/application_controller.rb

104 lines
3.2 KiB
Ruby
Raw Normal View History

2018-06-26 10:29:46 -04:00
# frozen_string_literal: true
2018-08-01 09:45:12 -04:00
# 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/>.
2018-05-07 16:06:01 -04:00
require 'bigbluebutton_api'
class ApplicationController < ActionController::Base
include SessionsHelper
2018-07-05 17:25:59 -04:00
before_action :migration_error?
2018-07-13 11:04:32 -04:00
before_action :set_locale
# Force SSL for loadbalancer configurations.
before_filter :redirect_to_https
2018-07-13 11:04:32 -04:00
protect_from_forgery with: :exception
MEETING_NAME_LIMIT = 90
2018-07-24 11:05:25 -04:00
USER_NAME_LIMIT = 32
2018-07-05 17:25:59 -04:00
# Show an information page when migration fails and there is a version error.
def migration_error?
render :migration_error unless ENV["DB_MIGRATE_FAILED"].blank?
end
2018-07-13 11:04:32 -04:00
# Sets the appropriate locale.
def set_locale
I18n.locale = http_accept_language.language_region_compatible_from(I18n.available_locales)
end
2018-05-07 16:06:01 -04:00
def meeting_name_limit
MEETING_NAME_LIMIT
end
helper_method :meeting_name_limit
def user_name_limit
USER_NAME_LIMIT
end
helper_method :user_name_limit
2018-06-21 10:57:20 -04:00
# Relative root helper (when deploying to subdirectory).
def relative_root
Rails.configuration.relative_url_root || ""
end
helper_method :relative_root
2018-05-07 16:06:01 -04:00
# Determines if the BigBlueButton endpoint is configured (or set to default).
def bigbluebutton_endpoint_default?
2018-05-11 15:57:31 -04:00
return false if loadbalanced_configuration?
2018-05-07 16:06:01 -04:00
Rails.configuration.bigbluebutton_endpoint_default == Rails.configuration.bigbluebutton_endpoint
end
helper_method :bigbluebutton_endpoint_default?
2018-05-11 15:57:31 -04:00
def loadbalanced_configuration?
Rails.configuration.loadbalanced_configuration
end
helper_method :loadbalanced_configuration?
def recording_thumbnails?
Rails.configuration.recording_thumbnails
end
helper_method :recording_thumbnails?
2018-05-11 15:57:31 -04:00
def allow_greenlight_users?
Rails.configuration.greenlight_accounts
end
helper_method :allow_greenlight_users?
2018-06-08 14:44:08 -04:00
# Determines if a form field needs the is-invalid class.
def form_is_invalid?(obj, key)
2018-06-26 10:29:46 -04:00
'is-invalid' unless obj.errors.messages[key].empty?
2018-06-08 14:44:08 -04:00
end
helper_method :form_is_invalid?
2018-06-26 10:29:46 -04:00
2018-05-15 11:43:59 -04:00
# Default, unconfigured meeting options.
def default_meeting_options
2018-07-19 16:04:08 -04:00
invite_msg = I18n.t("invite_message")
2018-05-15 11:43:59 -04:00
{
user_is_moderator: false,
2018-05-29 15:28:29 -04:00
meeting_logout_url: request.base_url + logout_room_path(@room),
2018-05-15 11:43:59 -04:00
meeting_recorded: true,
2018-07-19 16:04:08 -04:00
moderator_message: "#{invite_msg}\n\n#{request.base_url + room_path(@room)}",
2018-05-15 11:43:59 -04:00
}
2018-05-07 16:06:01 -04:00
end
def redirect_to_https
2018-08-15 11:49:13 -04:00
redirect_to protocol: "https://" if loadbalanced_configuration? && request.headers["X-Forwarded-Proto"] == "http"
end
2018-05-07 16:06:01 -04:00
end