Added All Join as Moderator room setting (#696)

This commit is contained in:
farhatahmad 2019-07-31 11:34:31 -04:00 committed by Jesus Federico
parent 5f237194b1
commit 973c95339c
6 changed files with 45 additions and 10 deletions

View File

@ -161,4 +161,14 @@ input:focus, select:focus {
background-color: $primary-color-darken !important;
border-color: $primary-color-darken !important;
color: white !important;
}
.custom-switch-input:checked ~ .custom-switch-indicator {
background-color: $primary-color !important;
border-color: $primary-color-darken !important;
}
.custom-switch-input:focus ~ .custom-switch-indicator {
box-shadow: 0 0 0 2px $primary-color-lighten;
border-color: $primary-color-darken !important;
}

View File

@ -39,7 +39,7 @@ class RoomsController < ApplicationController
@room = Room.new(name: room_params[:name], access_code: room_params[:access_code])
@room.owner = current_user
@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], room_params[:all_join_moderator])
if @room.save
if room_params[:auto_join] == "1"
@ -203,7 +203,7 @@ class RoomsController < ApplicationController
@room.update_attributes(name: params[:room_name] || room_params[:name])
elsif update_type.eql? "settings"
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_params[:all_join_moderator])
@room.update_attributes(room_settings: room_settings_string)
elsif update_type.eql? "access_code"
@room.update_attributes(access_code: room_params[:access_code])
@ -211,7 +211,7 @@ class RoomsController < ApplicationController
end
end
def create_room_settings_string(mute_res, require_approval_res, start_res)
def create_room_settings_string(mute_res, require_approval_res, start_res, join_mod)
room_settings = {}
room_settings["muteOnStart"] = mute_res == "1"
@ -219,12 +219,14 @@ class RoomsController < ApplicationController
room_settings["anyoneCanStart"] = start_res == "1"
room_settings["joinModerator"] = join_mod == "1"
room_settings.to_json
end
def room_params
params.require(:room).permit(:name, :auto_join, :mute_on_join, :access_code,
:require_moderator_approval, :anyone_can_start)
:require_moderator_approval, :anyone_can_start, :all_join_moderator)
end
# Find the room from the uid.
@ -297,8 +299,7 @@ class RoomsController < ApplicationController
if @room.running? || @room.owned_by?(current_user) || room_settings["anyoneCanStart"]
# Determine if the user needs to join as a moderator.
opts[:user_is_moderator] = @room.owned_by?(current_user) ||
(room_settings["anyoneCanStart"] && !@room.running?)
opts[:user_is_moderator] = @room.owned_by?(current_user) || room_settings["joinModerator"]
opts[:require_moderator_approval] = room_settings["requireModeratorApproval"]

View File

@ -67,6 +67,14 @@
</label>
<% end %>
<% if Rails.configuration.room_features.include? "all-join-moderator" %>
<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.join_moderator")%></span>
<%= f.check_box :all_join_moderator, class: "custom-switch-input", checked: false %>
<span class="custom-switch-indicator float-right cursor-pointer"></span>
</label>
<% end %>
<label id="auto-join-label" class="create-only custom-switch pl-0 mt-3 mb-3 w-100 text-left d-inline-block">
<span class="custom-switch-description"><%= t("modal.create_room.auto_join") %></span>
<%= f.check_box :auto_join, class: "custom-switch-input", checked: false %>

View File

@ -295,6 +295,7 @@ en:
title: Room Settings
update: Update Room
client: Select client type
join_moderator: All users join as moderators
mute: Mute users when they join
require_approval: Require moderator approval before joining
start: Allow any user to start this meeting

View File

@ -128,7 +128,8 @@ RELATIVE_URL_ROOT=/b
# 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
# anyone-can-start: Allows anyone with the join url to start the room in BigBlueButton
ROOM_FEATURES=mute-on-join,require-moderator-approval,anyone-can-start
# all-join-moderator: All users join as moderators in BigBlueButton
ROOM_FEATURES=mute-on-join,require-moderator-approval,anyone-can-start,all-join-moderator
# Specify the maximum number of records to be sent to the BigBlueButton API in one call
# Default is set to 25 records

View File

@ -120,9 +120,9 @@ describe RoomsController, type: :controller do
name = Faker::Games::Pokemon.name
room_params = { name: name, "mute_on_join": "1",
"require_moderator_approval": "1", "anyone_can_start": "1" }
"require_moderator_approval": "1", "anyone_can_start": "1", "all_join_moderator": "1" }
json_room_settings = "{\"muteOnStart\":true,\"requireModeratorApproval\":true," \
"\"anyoneCanStart\":true}"
"\"anyoneCanStart\":true,\"joinModerator\":true}"
post :create, params: { room: room_params }
@ -216,6 +216,20 @@ describe RoomsController, type: :controller do
@request.session[:user_id] = @user.id
post :join, params: { room_uid: room, join_name: @user.name }
expect(response).to redirect_to(room.join_path(@user.name, { user_is_moderator: false }, @user.uid))
end
it "should join the room as moderator if room has the all_join_moderator setting" do
allow_any_instance_of(BigBlueButton::BigBlueButtonApi).to receive(:is_meeting_running?).and_return(true)
room = Room.new(name: "test")
room.room_settings = "{\"joinModerator\":true}"
room.owner = @owner
room.save
@request.session[:user_id] = @user.id
post :join, params: { room_uid: room, join_name: @user.name }
expect(response).to redirect_to(room.join_path(@user.name, { user_is_moderator: true }, @user.uid))
end
@ -360,7 +374,7 @@ describe RoomsController, type: :controller do
room_params = { "mute_on_join": "1", "name": @secondary_room.name }
formatted_room_params = "{\"muteOnStart\":true,\"requireModeratorApproval\":false," \
"\"anyoneCanStart\":false}" # JSON string format
"\"anyoneCanStart\":false,\"joinModerator\":false}" # JSON string format
expect { post :update_settings, params: { room_uid: @secondary_room.uid, room: room_params } }
.to change { @secondary_room.reload.room_settings }