Skip to content

Commit

Permalink
Revert "LTI-321: Pull Default Room Setting Values From Broker (feat) (#…
Browse files Browse the repository at this point in the history
…290)" (#298)

This reverts commit 9e82848.
  • Loading branch information
jfederico authored Apr 11, 2024
1 parent 9e82848 commit c6abbcc
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 44 deletions.
4 changes: 0 additions & 4 deletions app/controllers/concerns/broker_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
54 changes: 14 additions & 40 deletions app/models/room.rb
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,6 @@ class Room < ApplicationRecord

attr_accessor :can_grade

include BrokerHelper

RECORDING_SETTINGS = [:record, :autoStartRecording, :allowStartStopRecording].freeze
CODE_LENGTH = 10

Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit c6abbcc

Please sign in to comment.