forked from External/greenlight
		
	* Room setting to allow anyone to start a room * Update sample.env * merge v2.2.1
This commit is contained in:
		
				
					committed by
					
						 Jesus Federico
						Jesus Federico
					
				
			
			
				
	
			
			
			
						parent
						
							b23f94dfb5
						
					
				
				
					commit
					d3a9ae32a9
				
			| @@ -50,6 +50,7 @@ $(document).on('turbolinks:load', function(){ | |||||||
|     $("#createRoomModal form").attr("action", $("body").data('relative-root')) |     $("#createRoomModal form").attr("action", $("body").data('relative-root')) | ||||||
|     updateDropdown($(".dropdown-item[value='default']")) |     updateDropdown($(".dropdown-item[value='default']")) | ||||||
|     $("#room_mute_on_join").prop("checked", false) |     $("#room_mute_on_join").prop("checked", false) | ||||||
|  |     $("#room_anyone_can_start").prop("checked", false) | ||||||
|  |  | ||||||
|     //show all elements & their children with a create-only class |     //show all elements & their children with a create-only class | ||||||
|     $(".create-only").each(function() { |     $(".create-only").each(function() { | ||||||
| @@ -104,6 +105,12 @@ $(document).on('turbolinks:load', function(){ | |||||||
|       $("#room_mute_on_join").prop("checked", false) |       $("#room_mute_on_join").prop("checked", false) | ||||||
|     } |     } | ||||||
|  |  | ||||||
|  |     if(settings.anyoneCanStart){ | ||||||
|  |       $("#room_anyone_can_start").prop("checked", true) | ||||||
|  |     } else { //default option | ||||||
|  |       $("#room_anyone_can_start").prop("checked", false) | ||||||
|  |     } | ||||||
|  |  | ||||||
|     //set dropdown value |     //set dropdown value | ||||||
|     if (settings.joinViaHtml5) { |     if (settings.joinViaHtml5) { | ||||||
|       updateDropdown($(".dropdown-item[value='html5']")) |       updateDropdown($(".dropdown-item[value='html5']")) | ||||||
|   | |||||||
| @@ -38,7 +38,8 @@ 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[:client], | ||||||
|  |       room_params[:anyone_can_start]) | ||||||
|  |  | ||||||
|     if @room.save |     if @room.save | ||||||
|       if room_params[:auto_join] == "1" |       if room_params[:auto_join] == "1" | ||||||
| @@ -55,13 +56,15 @@ class RoomsController < ApplicationController | |||||||
|  |  | ||||||
|   # GET /:room_uid |   # GET /:room_uid | ||||||
|   def show |   def show | ||||||
|  |     @is_running = @room.running? | ||||||
|  |     @anyone_can_start = JSON.parse(@room[:room_settings])["anyoneCanStart"] | ||||||
|  |  | ||||||
|     if current_user && @room.owned_by?(current_user) |     if current_user && @room.owned_by?(current_user) | ||||||
|       @search, @order_column, @order_direction, recs = |       @search, @order_column, @order_direction, recs = | ||||||
|         recordings(@room.bbb_id, @user_domain, params.permit(:search, :column, :direction), true) |         recordings(@room.bbb_id, @user_domain, params.permit(:search, :column, :direction), true) | ||||||
|  |  | ||||||
|       @pagy, @recordings = pagy_array(recs) |       @pagy, @recordings = pagy_array(recs) | ||||||
|  |  | ||||||
|       @is_running = @room.running? |  | ||||||
|     else |     else | ||||||
|       # Get users name |       # Get users name | ||||||
|       @name = if current_user |       @name = if current_user | ||||||
| @@ -199,7 +202,8 @@ 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[:client], | ||||||
|  |           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" | ||||||
|         @room.update_attributes(access_code: room_params[:access_code]) |         @room.update_attributes(access_code: room_params[:access_code]) | ||||||
| @@ -207,7 +211,7 @@ class RoomsController < ApplicationController | |||||||
|     end |     end | ||||||
|   end |   end | ||||||
|  |  | ||||||
|   def create_room_settings_string(mute_res, client_res) |   def create_room_settings_string(mute_res, client_res, start_res) | ||||||
|     room_settings = {} |     room_settings = {} | ||||||
|     room_settings["muteOnStart"] = mute_res == "1" |     room_settings["muteOnStart"] = mute_res == "1" | ||||||
|  |  | ||||||
| @@ -217,11 +221,13 @@ class RoomsController < ApplicationController | |||||||
|       room_settings["joinViaHtml5"] = false |       room_settings["joinViaHtml5"] = false | ||||||
|     end |     end | ||||||
|  |  | ||||||
|  |     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, :client, :access_code, :anyone_can_start) | ||||||
|   end |   end | ||||||
|  |  | ||||||
|   # Find the room from the uid. |   # Find the room from the uid. | ||||||
| @@ -289,12 +295,15 @@ class RoomsController < ApplicationController | |||||||
|   end |   end | ||||||
|  |  | ||||||
|   def join_room(opts) |   def join_room(opts) | ||||||
|     if @room.running? || @room.owned_by?(current_user) |     room_settings = JSON.parse(@room[:room_settings]) | ||||||
|  |  | ||||||
|  |     if @room.running? || @room.owned_by?(current_user) || room_settings["anyoneCanStart"] | ||||||
|  |  | ||||||
|       # Determine if the user needs to join as a moderator. |       # Determine if the user needs to join as a moderator. | ||||||
|       opts[:user_is_moderator] = @room.owned_by?(current_user) |       opts[:user_is_moderator] = @room.owned_by?(current_user) || | ||||||
|  |                                  (room_settings["anyoneCanStart"] && !@room.running?) | ||||||
|  |  | ||||||
|       # Check if the user has specified which client to use |       # Check if the user has specified which client to use | ||||||
|       room_settings = JSON.parse(@room[:room_settings]) |  | ||||||
|       opts[:join_via_html5] = room_settings["joinViaHtml5"] if room_settings["joinViaHtml5"] |       opts[:join_via_html5] = room_settings["joinViaHtml5"] if room_settings["joinViaHtml5"] | ||||||
|  |  | ||||||
|       if current_user |       if current_user | ||||||
|   | |||||||
| @@ -40,7 +40,7 @@ | |||||||
|             placeholder: t("enter_your_name"), |             placeholder: t("enter_your_name"), | ||||||
|             value: "#{@name}", |             value: "#{@name}", | ||||||
|             readonly: !current_user.nil? %> |             readonly: !current_user.nil? %> | ||||||
|         <%= f.submit t("room.join"), class: "btn btn-primary btn-sm col-sm-3 form-control join-form" %> |         <%= f.submit (!@is_running && @anyone_can_start)? t("room.start") : t("room.join"), class: "btn btn-primary btn-sm col-sm-3 form-control join-form" %> | ||||||
|       </div> |       </div> | ||||||
|     <% end %> |     <% end %> | ||||||
|   <% end %> |   <% end %> | ||||||
|   | |||||||
| @@ -68,6 +68,14 @@ | |||||||
|               </label> |               </label> | ||||||
|             <% end %> |             <% end %> | ||||||
|  |  | ||||||
|  |             <% if Rails.configuration.room_features.include? "anyone-can-start" %> | ||||||
|  |               <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.start")%></span> | ||||||
|  |                 <%= f.check_box :anyone_can_start, class: "custom-switch-input", checked: false %> | ||||||
|  |                 <span class="custom-switch-indicator float-right"></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"> |             <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> |               <span class="custom-switch-description"><%= t("modal.create_room.auto_join") %></span> | ||||||
|               <%= f.check_box :auto_join, class: "custom-switch-input", checked: false %> |               <%= f.check_box :auto_join, class: "custom-switch-input", checked: false %> | ||||||
|   | |||||||
| @@ -292,6 +292,7 @@ en: | |||||||
|       update: Update Room |       update: Update Room | ||||||
|       client: Select client type |       client: Select client type | ||||||
|       mute: Mute users when they join |       mute: Mute users when they join | ||||||
|  |       start: Allow any user to start this meeting | ||||||
|       default: Default |       default: Default | ||||||
|       html: HTML5 |       html: HTML5 | ||||||
|       flash: Flash |       flash: Flash | ||||||
|   | |||||||
| @@ -125,7 +125,8 @@ RELATIVE_URL_ROOT=/b | |||||||
| # Current settings available: | # Current settings available: | ||||||
| #   default-client: Room owners can decide between the Flash Client and the HTML5 Client for a room | #   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 | ||||||
| ROOM_FEATURES=default-client,mute-on-join | #   anyone-can-start: Allows anyone with the join url to start the room in BigBlueButton | ||||||
|  | ROOM_FEATURES=default-client,mute-on-join,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 | ||||||
|   | |||||||
| @@ -119,8 +119,8 @@ 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, "client": "html5", "mute_on_join": "1", "anyone_can_start": "1" } | ||||||
|       json_room_settings = "{\"muteOnStart\":true,\"joinViaHtml5\":true}" |       json_room_settings = "{\"muteOnStart\":true,\"joinViaHtml5\":true,\"anyoneCanStart\":true}" | ||||||
|  |  | ||||||
|       post :create, params: { room: room_params } |       post :create, params: { room: room_params } | ||||||
|  |  | ||||||
| @@ -203,6 +203,20 @@ describe RoomsController, type: :controller do | |||||||
|       expect(response).to render_template(:wait) |       expect(response).to render_template(:wait) | ||||||
|     end |     end | ||||||
|  |  | ||||||
|  |     it "should join the room if the room has the anyone_can_start setting" do | ||||||
|  |       allow_any_instance_of(BigBlueButton::BigBlueButtonApi).to receive(:is_meeting_running?).and_return(false) | ||||||
|  |  | ||||||
|  |       room = Room.new(name: "test") | ||||||
|  |       room.room_settings = "{\"muteOnStart\":false,\"joinViaHtml5\":false,\"anyoneCanStart\":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 | ||||||
|  |  | ||||||
|     it "should render wait if the correct access code is supplied" do |     it "should render wait if the correct access code is supplied" do | ||||||
|       allow_any_instance_of(BigBlueButton::BigBlueButtonApi).to receive(:is_meeting_running?).and_return(false) |       allow_any_instance_of(BigBlueButton::BigBlueButtonApi).to receive(:is_meeting_running?).and_return(false) | ||||||
|  |  | ||||||
| @@ -343,7 +357,8 @@ describe RoomsController, type: :controller 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 = { "client": "html5", "mute_on_join": "1", "name": @secondary_room.name } | ||||||
|       formatted_room_params = "{\"muteOnStart\":true,\"joinViaHtml5\":true}" # JSON string format |       formatted_room_params = "{\"muteOnStart\":true,\"joinViaHtml5\":true,\"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 } | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user