GRN2-206: Remove support for the flash client Fixes(#654) (#661)

* Remove ability to specify flash client

* Always join via html5

* Fix styling and tests
This commit is contained in:
shawn-higgins1 2019-07-24 09:37:59 -04:00 committed by Jesus Federico
parent 4e31366012
commit 0934919e44
8 changed files with 14 additions and 59 deletions

View File

@ -48,7 +48,6 @@ $(document).on('turbolinks:load', function(){
$("#room_access_code").val(null) $("#room_access_code").val(null)
$("#createRoomModal form").attr("action", $("body").data('relative-root')) $("#createRoomModal form").attr("action", $("body").data('relative-root'))
updateDropdown($(".dropdown-item[value='default']"))
$("#room_mute_on_join").prop("checked", false) $("#room_mute_on_join").prop("checked", false)
$("#room_require_moderator_approval").prop("checked", false) $("#room_require_moderator_approval").prop("checked", false)
$("#room_anyone_can_start").prop("checked", false) $("#room_anyone_can_start").prop("checked", false)
@ -117,24 +116,9 @@ $(document).on('turbolinks:load', function(){
} else { //default option } else { //default option
$("#room_anyone_can_start").prop("checked", false) $("#room_anyone_can_start").prop("checked", false)
} }
//set dropdown value
if (settings.joinViaHtml5) {
updateDropdown($(".dropdown-item[value='html5']"))
} else if (settings.joinViaHtml5 === false) {
updateDropdown($(".dropdown-item[value='flash']"))
} else { //default option
updateDropdown($(".dropdown-item[value='default']"))
}
} }
}); });
// Updates the dropdown element to show the clicked/correct text
function updateDropdown(element) {
$("#dropdown-trigger").text(element.text())
$("#room_client").val(element.val())
}
function generateAccessCode(){ function generateAccessCode(){
const accessCodeLength = 6 const accessCodeLength = 6
var validCharacters = "0123456789" var validCharacters = "0123456789"

View File

@ -38,7 +38,7 @@ class RoomsController < ApplicationController
@room = Room.new(name: room_params[:name], access_code: room_params[:access_code]) @room = Room.new(name: room_params[:name], access_code: room_params[:access_code])
@room.owner = current_user @room.owner = current_user
@room.room_settings = create_room_settings_string(room_params[:mute_on_join], room_params[:client], @room.room_settings = create_room_settings_string(room_params[:mute_on_join],
room_params[:require_moderator_approval], room_params[:anyone_can_start]) room_params[:require_moderator_approval], room_params[:anyone_can_start])
if @room.save if @room.save
@ -147,7 +147,6 @@ class RoomsController < ApplicationController
# Include the user's choices for the room settings # Include the user's choices for the room settings
room_settings = JSON.parse(@room[:room_settings]) room_settings = JSON.parse(@room[:room_settings])
opts[:mute_on_start] = room_settings["muteOnStart"] if room_settings["muteOnStart"] opts[:mute_on_start] = room_settings["muteOnStart"] if room_settings["muteOnStart"]
opts[:join_via_html5] = room_settings["joinViaHtml5"] if room_settings["joinViaHtml5"]
opts[:require_moderator_approval] = room_settings["requireModeratorApproval"] opts[:require_moderator_approval] = room_settings["requireModeratorApproval"]
begin begin
@ -203,7 +202,7 @@ class RoomsController < ApplicationController
if update_type.eql? "name" if update_type.eql? "name"
@room.update_attributes(name: params[:room_name] || room_params[:name]) @room.update_attributes(name: params[:room_name] || room_params[:name])
elsif update_type.eql? "settings" elsif update_type.eql? "settings"
room_settings_string = create_room_settings_string(room_params[:mute_on_join], room_params[:client], room_settings_string = create_room_settings_string(room_params[:mute_on_join],
room_params[:require_moderator_approval], room_params[:anyone_can_start]) room_params[:require_moderator_approval], room_params[:anyone_can_start])
@room.update_attributes(room_settings: room_settings_string) @room.update_attributes(room_settings: room_settings_string)
elsif update_type.eql? "access_code" elsif update_type.eql? "access_code"
@ -212,25 +211,19 @@ class RoomsController < ApplicationController
end end
end end
def create_room_settings_string(mute_res, client_res, require_approval_res, start_res) def create_room_settings_string(mute_res, require_approval_res, start_res)
room_settings = {} room_settings = {}
room_settings["muteOnStart"] = mute_res == "1" room_settings["muteOnStart"] = mute_res == "1"
room_settings["requireModeratorApproval"] = require_approval_res == "1" room_settings["requireModeratorApproval"] = require_approval_res == "1"
if client_res.eql? "html5"
room_settings["joinViaHtml5"] = true
elsif client_res.eql? "flash"
room_settings["joinViaHtml5"] = false
end
room_settings["anyoneCanStart"] = start_res == "1" room_settings["anyoneCanStart"] = start_res == "1"
room_settings.to_json room_settings.to_json
end end
def room_params def room_params
params.require(:room).permit(:name, :auto_join, :mute_on_join, :client, :access_code, params.require(:room).permit(:name, :auto_join, :mute_on_join, :access_code,
:require_moderator_approval, :anyone_can_start) :require_moderator_approval, :anyone_can_start)
end end
@ -307,8 +300,6 @@ class RoomsController < ApplicationController
opts[:user_is_moderator] = @room.owned_by?(current_user) || opts[:user_is_moderator] = @room.owned_by?(current_user) ||
(room_settings["anyoneCanStart"] && !@room.running?) (room_settings["anyoneCanStart"] && !@room.running?)
# Check if the user has specified which client to use
opts[:join_via_html5] = room_settings["joinViaHtml5"] if room_settings["joinViaHtml5"]
opts[:require_moderator_approval] = room_settings["requireModeratorApproval"] opts[:require_moderator_approval] = room_settings["requireModeratorApproval"]
if current_user if current_user

View File

@ -104,7 +104,7 @@ class Room < ApplicationRecord
# Generate the join URL. # Generate the join URL.
join_opts = {} join_opts = {}
join_opts[:userID] = uid if uid join_opts[:userID] = uid if uid
join_opts[:joinViaHtml5] = options[:join_via_html5] if options[:join_via_html5] join_opts[:join_via_html5] = true
join_opts[:guest] = true if options[:require_moderator_approval] && !options[:user_is_moderator] join_opts[:guest] = true if options[:require_moderator_approval] && !options[:user_is_moderator]

View File

@ -43,23 +43,6 @@
</span> </span>
</div> </div>
<% if Rails.configuration.room_features.include? "default-client" %>
<label class="mt-3 mb-3 w-100 text-left d-inline-block">
<input type="hidden" name="room[client]" id="room_client">
<span id="room-settings-dropdown-label" class="custom-switch-description"><%= t("modal.room_settings.client")%></span>
<div id="dropdown-div" class="dropdown float-right">
<button id="dropdown-trigger" type="button" class="btn btn-secondary dropdown-toggle px-4" data-toggle="dropdown">
<%= t("modal.room_settings.default")%>
</button>
<div class="dropdown-menu">
<button type=button class="dropdown-item" onclick="updateDropdown($(this))" value="default"><%= t("modal.room_settings.default")%></button>
<button type=button class="dropdown-item" onclick="updateDropdown($(this))" value="html5"><%= t("modal.room_settings.html")%></button>
<button type=button class="dropdown-item" onclick="updateDropdown($(this))" value="flash"><%= t("modal.room_settings.flash")%></button>
</div>
</div>
</label>
<% end %>
<% if Rails.configuration.room_features.include? "mute-on-join" %> <% if Rails.configuration.room_features.include? "mute-on-join" %>
<label class="custom-switch pl-0 mt-3 mb-3 w-100 text-left d-inline-block"> <label class="custom-switch pl-0 mt-3 mb-3 w-100 text-left d-inline-block">
<span class="custom-switch-description"><%= t("modal.room_settings.mute")%></span> <span class="custom-switch-description"><%= t("modal.room_settings.mute")%></span>

View File

@ -301,9 +301,6 @@ en:
mute: Mute users when they join mute: Mute users when they join
require_approval: Require moderator approval before joining require_approval: Require moderator approval before joining
start: Allow any user to start this meeting start: Allow any user to start this meeting
default: Default
html: HTML5
flash: Flash
footer_text: Adjustment to your room can be done at anytime. footer_text: Adjustment to your room can be done at anytime.
rename_room: rename_room:
name_placeholder: Enter a new room name... name_placeholder: Enter a new room name...

View File

@ -123,11 +123,10 @@ RELATIVE_URL_ROOT=/b
# By default, all settings are turned OFF. # By default, all settings are turned OFF.
# #
# Current settings available: # Current settings available:
# default-client: Room owners can decide between the Flash Client and the HTML5 Client for a room
# mute-on-join: Automatically mute users by default when they join a room # mute-on-join: Automatically mute users by default when they join a room
# require-moderator-approval: Require moderators to approve new users before they can join the room # require-moderator-approval: Require moderators to approve new users before they can join the room
# anyone-can-start: Allows anyone with the join url to start the room in BigBlueButton # anyone-can-start: Allows anyone with the join url to start the room in BigBlueButton
ROOM_FEATURES=default-client,mute-on-join,require-moderator-approval,anyone-can-start ROOM_FEATURES=mute-on-join,require-moderator-approval,anyone-can-start
# Specify the maximum number of records to be sent to the BigBlueButton API in one call # Specify the maximum number of records to be sent to the BigBlueButton API in one call
# Default is set to 25 records # Default is set to 25 records

View File

@ -119,10 +119,10 @@ describe RoomsController, type: :controller do
@request.session[:user_id] = @owner.id @request.session[:user_id] = @owner.id
name = Faker::Games::Pokemon.name name = Faker::Games::Pokemon.name
room_params = { name: name, "client": "html5", "mute_on_join": "1", room_params = { name: name, "mute_on_join": "1",
"require_moderator_approval": "1", "anyone_can_start": "1" } "require_moderator_approval": "1", "anyone_can_start": "1" }
json_room_settings = "{\"muteOnStart\":true,\"requireModeratorApproval\":true," \ json_room_settings = "{\"muteOnStart\":true,\"requireModeratorApproval\":true," \
"\"joinViaHtml5\":true,\"anyoneCanStart\":true}" "\"anyoneCanStart\":true}"
post :create, params: { room: room_params } post :create, params: { room: room_params }
@ -145,7 +145,7 @@ describe RoomsController, type: :controller do
it "should redirect back to main room with error if it fails" do it "should redirect back to main room with error if it fails" do
@request.session[:user_id] = @owner.id @request.session[:user_id] = @owner.id
room_params = { name: "", "client": "html5", "mute_on_join": "1" } room_params = { name: "", "mute_on_join": "1" }
post :create, params: { room: room_params } post :create, params: { room: room_params }
@ -158,7 +158,7 @@ describe RoomsController, type: :controller do
@request.session[:user_id] = @owner.id @request.session[:user_id] = @owner.id
room_params = { name: Faker::Games::Pokemon.name, "client": "html5", "mute_on_join": "1" } room_params = { name: Faker::Games::Pokemon.name, "mute_on_join": "1" }
post :create, params: { room: room_params } post :create, params: { room: room_params }
@ -358,9 +358,9 @@ describe RoomsController, type: :controller do
it "properly updates room settings through the room settings modal and redirects to current page" do it "properly updates room settings through the room settings modal and redirects to current page" do
@request.session[:user_id] = @user.id @request.session[:user_id] = @user.id
room_params = { "client": "html5", "mute_on_join": "1", "name": @secondary_room.name } room_params = { "mute_on_join": "1", "name": @secondary_room.name }
formatted_room_params = "{\"muteOnStart\":true,\"requireModeratorApproval\":false," \ formatted_room_params = "{\"muteOnStart\":true,\"requireModeratorApproval\":false," \
"\"joinViaHtml5\":true,\"anyoneCanStart\":false}" # JSON string format "\"anyoneCanStart\":false}" # JSON string format
expect { post :update_settings, params: { room_uid: @secondary_room.uid, room: room_params } } expect { post :update_settings, params: { room_uid: @secondary_room.uid, room: room_params } }
.to change { @secondary_room.reload.room_settings } .to change { @secondary_room.reload.room_settings }

View File

@ -96,10 +96,11 @@ describe Room, type: :model do
endpoint = Rails.configuration.bigbluebutton_endpoint endpoint = Rails.configuration.bigbluebutton_endpoint
secret = Rails.configuration.bigbluebutton_secret secret = Rails.configuration.bigbluebutton_secret
fullname = "fullName=Example" fullname = "fullName=Example"
join_via_html5 = "&join_via_html5=true"
meeting_id = "&meetingID=#{@room.bbb_id}" meeting_id = "&meetingID=#{@room.bbb_id}"
password = "&password=testpass" password = "&password=testpass"
query = fullname + meeting_id + password query = fullname + join_via_html5 + meeting_id + password
checksum_string = "join#{query + secret}" checksum_string = "join#{query + secret}"
checksum = OpenSSL::Digest.digest('sha1', checksum_string).unpack1("H*") checksum = OpenSSL::Digest.digest('sha1', checksum_string).unpack1("H*")