diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index 8e5be0b3..f8866ca1 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -19,13 +19,19 @@ class UsersController < ActionController::Base # For updating a users background image. def update - # Make sure they actually select a file. - if params[:user] then + if params[:commit] == t('upload') + # Make sure they actually select a file. + if params[:user] then + @user = User.find(params[:id]) + @user.assign_attributes(background: user_params[:background]) + flash[:danger] = t('invalid_file') unless @user.save + else + flash[:danger] = t('no_file') + end + elsif params[:commit] == t('switch_clients') + # Switch the users default client. @user = User.find(params[:id]) - @user.assign_attributes(background: user_params[:background]) - flash[:danger] = t('invalid_file') unless @user.save - else - flash[:danger] = t('no_file') + @user.update_attributes(use_html5: !@user.use_html5) end # Reload the page to apply changes and show flash messages. diff --git a/app/lib/bbb_api.rb b/app/lib/bbb_api.rb index d0e3d89c..3c9a0701 100644 --- a/app/lib/bbb_api.rb +++ b/app/lib/bbb_api.rb @@ -80,6 +80,7 @@ module BbbApi "meta_#{BbbApi::META_LISTED}": false, "meta_#{BbbApi::META_TOKEN}": meeting_token } + meeting_options.merge!( { "meta_#{BbbApi::META_HOOK_URL}": options[:hook_url] } ) if options[:hook_url] @@ -116,7 +117,31 @@ module BbbApi else password = bbb_meeting_info[:attendeePW] end - join_url = bbb.join_meeting_url(meeting_id, full_name, password ) + + # Determine which client to join as. + if current_user.nil? + use_html5 = Rails.configuration.use_html5_by_default + else + use_html5 = current_user.use_html5 == true + end + + # If the user wants to use HTML5, verfiy it's running. + if use_html5 + html5_check = Faraday.get bbb_endpoint.gsub('bigbluebutton/', 'html5client/check') + # If HTML5 is not running, must use Flash. + unless html5_check.status == 200 + use_html5 = false + end + end + + # Generate the join URL. + if use_html5 + clientURL = bbb_endpoint.gsub('bigbluebutton/', 'html5client/join') + join_url = bbb.join_meeting_url(meeting_id, full_name, password, {clientURL: clientURL}) + else + join_url = bbb.join_meeting_url(meeting_id, full_name, password) + end + return success_join_res(join_url) end end diff --git a/app/views/landing/preferences.html.erb b/app/views/landing/preferences.html.erb index 542d8d3a..d69c459b 100644 --- a/app/views/landing/preferences.html.erb +++ b/app/views/landing/preferences.html.erb @@ -23,6 +23,7 @@ <% if @user %>
+

<%= t('background_image') %>

<%= t('background_image') + ": " + (@user.background_file_name || '') %>

<%= form_for @user, :html => { :multipart => true } do |f| %>
@@ -31,6 +32,14 @@ <%= f.submit t('upload'), class: 'btn btn-info' %> <% end %>
+
+
+

<%= t('prefered_client') %>

+

<%= t('currently_joining_with', client: @user.use_html5 ? t('client_html5') : t('client_flash')) %>

+ <%= form_for @user do |f| %> + <%= f.submit t('switch_clients'), class: 'btn btn-info' %> + <% end %> +
<% else %>

<%= t('preferences_logged') %>

<% end %> diff --git a/config/application.rb b/config/application.rb index 7102d908..37390904 100644 --- a/config/application.rb +++ b/config/application.rb @@ -48,6 +48,7 @@ module Greenlight config.disable_guest_access = ENV['DISABLE_GUEST_ACCESS'] && ENV['DISABLE_GUEST_ACCESS'] == "true" config.enable_youtube_uploading = ENV['ENABLE_YOUTUBE_UPLOADING'] && ENV['ENABLE_YOUTUBE_UPLOADING'] == "true" config.enable_qrcode_generation = ENV['ENABLE_QRCODE_GENERATION'] && ENV['ENABLE_QRCODE_GENERATION'] == "true" + config.use_html5_by_default = ENV['USE_HTML5_BY_DEFAULT'] == "true" # SMTP and action mailer if config.mail_notifications diff --git a/config/locales/en-us.yml b/config/locales/en-us.yml index 15a5de77..204a31a4 100644 --- a/config/locales/en-us.yml +++ b/config/locales/en-us.yml @@ -76,8 +76,11 @@ en-US: upload_youtube: Youtube user_waiting_body: "%{user} is waiting to join %{meeting}!" user_waiting_title: A user is waiting + client_html5: HTML5 + client_flash: Flash copied: Copied copy_error: Use Ctrl-c to copy + currently_joining_with: Currently joining with %{client} client. create_your_session: Create your own meeting date_recorded: Date disallowed_characters_msg: Characters not allowed in meeting name $&, @@ -157,6 +160,7 @@ en-US: past_recordings: Past Recordings preferences: Preferences preferences_logged: You must be logged in to edit preferences. + prefered_client: Prefered Client presentation: Presentation previous_meetings: (previous meetings) qrcode: @@ -176,6 +180,7 @@ en-US: start: Start start_join: Start start_meeting: Start meeting + switch_clients: Switch Clients test_mailer: test_email: subject: Test Email diff --git a/db/migrate/20170928183010_add_use_html5_to_users.rb b/db/migrate/20170928183010_add_use_html5_to_users.rb new file mode 100644 index 00000000..4518ea3f --- /dev/null +++ b/db/migrate/20170928183010_add_use_html5_to_users.rb @@ -0,0 +1,5 @@ +class AddUseHtml5ToUsers < ActiveRecord::Migration[5.0] + def change + add_column :users, :use_html5, :boolean, default: false + end +end diff --git a/db/schema.rb b/db/schema.rb index 4aff0bb8..cb2ba6a5 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -10,22 +10,23 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema.define(version: 20170518190442) do +ActiveRecord::Schema.define(version: 20170928183010) do create_table "users", force: :cascade do |t| - t.string "provider", null: false - t.string "uid", null: false + t.string "provider", null: false + t.string "uid", null: false t.string "name" - t.datetime "created_at", null: false - t.datetime "updated_at", null: false + t.datetime "created_at", null: false + t.datetime "updated_at", null: false t.string "username" - t.string "encrypted_id", null: false + t.string "encrypted_id", null: false t.string "email" t.string "background_file_name" t.string "background_content_type" t.integer "background_file_size" t.datetime "background_updated_at" t.string "token" + t.boolean "use_html5", default: true t.index ["email"], name: "index_users_on_email", unique: true t.index ["encrypted_id"], name: "index_users_on_encrypted_id", unique: true t.index ["provider", "uid"], name: "index_users_on_provider_and_uid", unique: true diff --git a/sample.env b/sample.env index b3781cb0..2fdb1dc2 100644 --- a/sample.env +++ b/sample.env @@ -23,6 +23,17 @@ SECRET_KEY_BASE= # BIGBLUEBUTTON_ENDPOINT= # BIGBLUEBUTTON_SECRET= +# Set default client (optional) +# +# By default, GreenLight will join users to a BigBlueButton session using the Flash +# client. By setting USE_HTML5_BY_DEFAULT to true, you can configure GreenLight to +# use the HTML5 client by default. GreenLight will only use the default for +# non-authenticated users. Users who have authenticated are able to set their +# prefered client under preferences. Also note that if the HTML5 client is not +# running on a BigBlueButton server, all clients will be joined using Flash +# regardless on any settings. +USE_HTML5_BY_DEFAULT=false + # Twitter Login Provider (optional) # # You will need to register the app at https://apps.twitter.com/