From c6abbcccd01fdfde0a25fd7a265927004385a14f Mon Sep 17 00:00:00 2001 From: Jesus Federico Date: Thu, 11 Apr 2024 16:22:15 -0400 Subject: [PATCH] Revert "LTI-321: Pull Default Room Setting Values From Broker (feat) (#290)" (#298) This reverts commit 9e82848e681163c956db67e3012edf05fc7fcdcb. --- app/controllers/concerns/broker_helper.rb | 4 -- app/models/room.rb | 54 ++++++----------------- 2 files changed, 14 insertions(+), 44 deletions(-) diff --git a/app/controllers/concerns/broker_helper.rb b/app/controllers/concerns/broker_helper.rb index 207215d0..89833b89 100644 --- a/app/controllers/concerns/broker_helper.rb +++ b/app/controllers/concerns/broker_helper.rb @@ -49,8 +49,4 @@ def hide_build_tag(tenant) def bbb_moderator_roles_params(tenant) tenant_settings(tenant: tenant)&.[]('settings')&.[]('bigbluebutton_moderator_roles')&.split(',') end - - def room_setting_defaults(tenant) - tenant_settings(tenant: tenant)&.dig('settings', 'room_setting_defaults') - end end diff --git a/app/models/room.rb b/app/models/room.rb index 17ea05f8..a22d8056 100644 --- a/app/models/room.rb +++ b/app/models/room.rb @@ -28,8 +28,6 @@ class Room < ApplicationRecord attr_accessor :can_grade - include BrokerHelper - RECORDING_SETTINGS = [:record, :autoStartRecording, :allowStartStopRecording].freeze CODE_LENGTH = 10 @@ -86,44 +84,20 @@ def delete_settings end def initialize_setting_defaults - # get the key value pair from the broker using the room_setting_defaults function - room_settings = room_setting_defaults(tenant) - - # Define default values - defaults = { - lockSettingsDisableCam: '0', - lockSettingsDisableMic: '0', - lockSettingsDisablePrivateChat: '0', - lockSettingsDisablePublicChat: '0', - lockSettingsDisableNote: '0', - autoStartRecording: '0', - allowStartStopRecording: '1', - waitForModerator: '1', - allModerators: '0', - record: '1', - } - - if room_settings.blank? - # If room_settings is not present or null, assign defaults directly - defaults.each do |key, value| - send("#{key}=", value) unless send("#{key}_changed?") - end - else - # Parse the values using the parse_defaults function - parsed_defaults = parse_defaults(room_settings) - - # Iterate over default values and set them using send method - defaults.each do |key, value| - send("#{key}=", parsed_defaults.fetch(key, value)) unless send("#{key}_changed?") - end - end - end - - def parse_defaults(defaults_str) - defaults_str.gsub(/[{}]/, '').split(',').map do |pair| - key, value = pair.split(':') - [key.strip.to_sym, value.strip] - end.to_h + self.lockSettingsDisableCam = '0' unless lockSettingsDisableCam_changed? + self.lockSettingsDisableMic = '0' unless lockSettingsDisableMic_changed? + self.lockSettingsDisablePrivateChat = '0' unless lockSettingsDisablePrivateChat_changed? + self.lockSettingsDisablePublicChat = '0' unless lockSettingsDisablePublicChat_changed? + self.lockSettingsDisableNote = '0' unless lockSettingsDisableNote_changed? + self.autoStartRecording = '0' unless autoStartRecording_changed? + self.allowStartStopRecording = '1' unless allowStartStopRecording_changed? + + # these settings existed as their own column in the db + # therefore we take the value in that column if it already exists + # this is done to ensure previous values are not overwritten. + self.waitForModerator = wait_moderator.nil? ? '1' : bool_to_binary(wait_moderator) unless waitForModerator_changed? + self.allModerators = all_moderators.nil? ? '0' : bool_to_binary(all_moderators) unless allModerators_changed? + self.record = record.nil? ? '1' : bool_to_binary(record) unless record_changed? end def bool_to_binary(value)