From 0630101c2a351fdac0fea356367652a1ebabcc0c Mon Sep 17 00:00:00 2001 From: Khemissi Amir Date: Tue, 18 Oct 2022 20:31:08 +0100 Subject: [PATCH 01/37] Resources migration: Added `migrations:roles` task. (#4001) --- config/application.rb | 4 ++ lib/tasks/migrations/migrations.rake | 64 ++++++++++++++++++++++++++++ sample.env | 7 +++ 3 files changed, 75 insertions(+) create mode 100644 lib/tasks/migrations/migrations.rake diff --git a/config/application.rb b/config/application.rb index d23746fd7a..c678a12fe8 100644 --- a/config/application.rb +++ b/config/application.rb @@ -51,6 +51,10 @@ def parse_bool(val, default = false) # The default callback url that bn launcher will redirect to config.gl_callback_url = ENV["GL_CALLBACK_URL"] + # Greenlight V3 variables: + config.v3_endpoint = ENV["V3_ENDPOINT"] + config.v3_secret_key_base = ENV["V3_SECRET_KEY_BASE"] + # Default credentials (test-install.blindsidenetworks.com/bigbluebutton). config.bigbluebutton_endpoint_default = "http://test-install.blindsidenetworks.com/bigbluebutton/api/" config.bigbluebutton_secret_default = "8cd8ef52e8e101574e400365b55e11a6" diff --git a/lib/tasks/migrations/migrations.rake b/lib/tasks/migrations/migrations.rake new file mode 100644 index 0000000000..f54c37f48c --- /dev/null +++ b/lib/tasks/migrations/migrations.rake @@ -0,0 +1,64 @@ +# frozen_string_literal: true + +namespace :migrations do + COMMON = { + headers: { "Content-Type" => "application/json" } + }.freeze + + desc "Migrates v2 resources to v3" + task :roles, [] => :environment do |_task, _args| + has_encountred_issue = 0 + + Role.select(:id, :name).where.not(name: Role::RESERVED_ROLE_NAMES).each do |r| + params = { role: { name: r.name } } + response = Net::HTTP.post(uri('roles'), payload(params), COMMON[:headers]) + + case response + when Net::HTTPCreated + puts green "Succesfully migrated Role:" + puts cyan " Name: #{r.name}" + else + puts red "Unable to migrate Role:" + puts red " Name: #{r.name}" + has_encountred_issue = 1 # At least one of the migrations failed. + end + end + + puts + puts green "Roles migration complete." + puts yellow "In case of an error please retry the process to resolve." unless has_encountred_issue.zero? + exit has_encountred_issue + end + + private + + def encrypt_params(params) + unless Rails.configuration.v3_secret_key_base.present? + raise red 'Unable to migrate: No "V3_SECRET_KEY_BASE" provided, please check your .env file.' + end + + unless Rails.configuration.v3_secret_key_base.size >= 32 + raise red 'Unable to migrate: Provided "V3_SECRET_KEY_BASE" must be at least 32 charchters in length.' + end + + key = Rails.configuration.v3_secret_key_base[0..31] + crypt = ActiveSupport::MessageEncryptor.new(key, cipher: 'aes-256-gcm', serializer: Marshal) + crypt.encrypt_and_sign(params, expires_in: 10.seconds) + end + + def uri(path) + unless Rails.configuration.v3_endpoint.present? + raise red 'Unable to migrate: No "V3_ENDPOINT" provided, please check your .env file.' + end + + res = URI(Rails.configuration.v3_endpoint) + res.path = "/api/v1/migrations/#{path}.json" + res + end + + def payload(params) + encrypted_params = { "encrypted_params" => encrypt_params(params) } + res = { "v2" => encrypted_params } + res.to_json + end +end diff --git a/sample.env b/sample.env index e8200fbcab..601f59163e 100644 --- a/sample.env +++ b/sample.env @@ -16,6 +16,13 @@ SECRET_KEY_BASE= BIGBLUEBUTTON_ENDPOINT= BIGBLUEBUTTON_SECRET= +# The endpoint and "SECRET_KEY_BASE" for your Greenlight v3 instance. +# Set these if you are trying to migrate your resources to v3. +# Example: +#V3_ENDPOINT=https://v3.greenlight.test/ +#V3_SECRET_KEY_BASE= +V3_ENDPOINT= +V3_SECRET_KEY_BASE= # The hostname that the application is accessible from. # # Used to protect against various HTTP header attacks From 779c15d9b1fd25922445f0e025d46df154df6eab Mon Sep 17 00:00:00 2001 From: Khemissi Amir Date: Thu, 20 Oct 2022 14:52:10 +0100 Subject: [PATCH 02/37] Resources migration: Added `migrations:users` task. (#4009) --- lib/tasks/migrations/migrations.rake | 39 +++++++++++++++++++++++++--- 1 file changed, 36 insertions(+), 3 deletions(-) diff --git a/lib/tasks/migrations/migrations.rake b/lib/tasks/migrations/migrations.rake index f54c37f48c..17ba57872a 100644 --- a/lib/tasks/migrations/migrations.rake +++ b/lib/tasks/migrations/migrations.rake @@ -16,10 +16,12 @@ namespace :migrations do case response when Net::HTTPCreated puts green "Succesfully migrated Role:" + puts cyan " ID: #{r.id}" puts cyan " Name: #{r.name}" else puts red "Unable to migrate Role:" - puts red " Name: #{r.name}" + puts yellow " ID: #{r.id}" + puts yellow " Name: #{r.name}" has_encountred_issue = 1 # At least one of the migrations failed. end end @@ -30,6 +32,38 @@ namespace :migrations do exit has_encountred_issue end + task :users, [] => :environment do |_task, _args| + has_encountred_issue = 0 + + # TODO: Optimize this by running in batches. + User.select(:id, :uid, :name, :email, :social_uid, :language, :role_id).each do |u| + params = { user: { name: u.name, email: u.email, external_id: u.social_uid, language: u.language, role: u.role.name } } + response = Net::HTTP.post(uri('users'), payload(params), COMMON[:headers]) + + case response + when Net::HTTPCreated + puts green "Succesfully migrated User:" + puts cyan " UID: #{u.uid}" + puts cyan " Name: #{params[:user][:name]}" + else + puts red "Unable to migrate User:" + puts yellow " UID: #{u.uid}" + puts yellow " Name: #{params[:user][:name]}" + has_encountred_issue = 1 # At least one of the migrations failed. + end + end + + puts + puts green "Users migration completed." + + unless has_encountred_issue.zero? + puts yellow "In case of an error please retry the process to resolve." + puts yellow "If you have not migrated your roles, kindly run 'rake migrations:roles' first and then retry." + end + + exit has_encountred_issue + end + private def encrypt_params(params) @@ -57,8 +91,7 @@ namespace :migrations do end def payload(params) - encrypted_params = { "encrypted_params" => encrypt_params(params) } - res = { "v2" => encrypted_params } + res = { "v2" => { "encrypted_params" => encrypt_params(params) } } res.to_json end end From 42373e2084ee889abc4c73a068eb1405c463a855 Mon Sep 17 00:00:00 2001 From: Khemissi Amir Date: Thu, 20 Oct 2022 19:30:30 +0100 Subject: [PATCH 03/37] Resources migration: Enabled migration tasks with batch processing. (#4010) --- lib/tasks/migrations/migrations.rake | 83 +++++++++++++++++----------- 1 file changed, 50 insertions(+), 33 deletions(-) diff --git a/lib/tasks/migrations/migrations.rake b/lib/tasks/migrations/migrations.rake index 17ba57872a..3c87f0a7e0 100644 --- a/lib/tasks/migrations/migrations.rake +++ b/lib/tasks/migrations/migrations.rake @@ -2,28 +2,31 @@ namespace :migrations do COMMON = { - headers: { "Content-Type" => "application/json" } + headers: { "Content-Type" => "application/json" }, + batch_size: 1000, }.freeze desc "Migrates v2 resources to v3" task :roles, [] => :environment do |_task, _args| has_encountred_issue = 0 - Role.select(:id, :name).where.not(name: Role::RESERVED_ROLE_NAMES).each do |r| - params = { role: { name: r.name } } - response = Net::HTTP.post(uri('roles'), payload(params), COMMON[:headers]) - - case response - when Net::HTTPCreated - puts green "Succesfully migrated Role:" - puts cyan " ID: #{r.id}" - puts cyan " Name: #{r.name}" - else - puts red "Unable to migrate Role:" - puts yellow " ID: #{r.id}" - puts yellow " Name: #{r.name}" - has_encountred_issue = 1 # At least one of the migrations failed. - end + Role.select(:id, :name) + .where.not(name: Role::RESERVED_ROLE_NAMES) + .find_each(batch_size: COMMON[:batch_size]) do |r| + params = { role: { name: r.name } } + response = Net::HTTP.post(uri('roles'), payload(params), COMMON[:headers]) + + case response + when Net::HTTPCreated + puts green "Succesfully migrated Role:" + puts cyan " ID: #{r.id}" + puts cyan " Name: #{params[:role][:name]}" + else + puts red "Unable to migrate Role:" + puts yellow " ID: #{r.id}" + puts yellow " Name: #{params[:role][:name]}" + has_encountred_issue = 1 # At least one of the migrations failed. + end end puts @@ -32,25 +35,27 @@ namespace :migrations do exit has_encountred_issue end - task :users, [] => :environment do |_task, _args| + task :users, [:start, :stop] => :environment do |_task, args| + start, stop = range(args) + has_encountred_issue = 0 - # TODO: Optimize this by running in batches. - User.select(:id, :uid, :name, :email, :social_uid, :language, :role_id).each do |u| - params = { user: { name: u.name, email: u.email, external_id: u.social_uid, language: u.language, role: u.role.name } } - response = Net::HTTP.post(uri('users'), payload(params), COMMON[:headers]) - - case response - when Net::HTTPCreated - puts green "Succesfully migrated User:" - puts cyan " UID: #{u.uid}" - puts cyan " Name: #{params[:user][:name]}" - else - puts red "Unable to migrate User:" - puts yellow " UID: #{u.uid}" - puts yellow " Name: #{params[:user][:name]}" - has_encountred_issue = 1 # At least one of the migrations failed. - end + User.select(:id, :uid, :name, :email, :social_uid, :language, :role_id) + .find_each(start: start, finish: stop, batch_size: COMMON[:batch_size]) do |u| + params = { user: { name: u.name, email: u.email, external_id: u.social_uid, language: u.language, role: u.role.name } } + response = Net::HTTP.post(uri('users'), payload(params), COMMON[:headers]) + + case response + when Net::HTTPCreated + puts green "Succesfully migrated User:" + puts cyan " UID: #{u.uid}" + puts cyan " Name: #{params[:user][:name]}" + else + puts red "Unable to migrate User:" + puts yellow " UID: #{u.uid}" + puts yellow " Name: #{params[:user][:name]}" + has_encountred_issue = 1 # At least one of the migrations failed. + end end puts @@ -94,4 +99,16 @@ namespace :migrations do res = { "v2" => { "encrypted_params" => encrypt_params(params) } } res.to_json end + + def range(args) + start = args[:start].to_i + start = 1 unless start.positive? + + stop = args[:stop].to_i + stop = nil unless stop.positive? + + raise red "Unable to migrate: Invalid provided range [start: #{start}, finish: #{stop}]" if stop && start > stop + + [start, stop] + end end From e2fc50afbc51d8c737afa241074bfcf4f4fbcba3 Mon Sep 17 00:00:00 2001 From: Khemissi Amir Date: Fri, 21 Oct 2022 15:53:08 +0100 Subject: [PATCH 04/37] Resources migration: Minor improvement to tasks. (#4015) + Added capitalization on migrated roles names. + Auto mapping of v2 default roles names to v3 names. + Better filtering to migrated users records. --- lib/tasks/migrations/migrations.rake | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/lib/tasks/migrations/migrations.rake b/lib/tasks/migrations/migrations.rake index 3c87f0a7e0..4c9c9f214e 100644 --- a/lib/tasks/migrations/migrations.rake +++ b/lib/tasks/migrations/migrations.rake @@ -1,6 +1,7 @@ # frozen_string_literal: true namespace :migrations do + DEFAULT_ROLES_MAP = { "admin" => "Administrator", "user" => "User" }.freeze COMMON = { headers: { "Content-Type" => "application/json" }, batch_size: 1000, @@ -13,7 +14,7 @@ namespace :migrations do Role.select(:id, :name) .where.not(name: Role::RESERVED_ROLE_NAMES) .find_each(batch_size: COMMON[:batch_size]) do |r| - params = { role: { name: r.name } } + params = { role: { name: r.name.capitalize } } response = Net::HTTP.post(uri('roles'), payload(params), COMMON[:headers]) case response @@ -39,10 +40,14 @@ namespace :migrations do start, stop = range(args) has_encountred_issue = 0 + filtered_roles_names = Role::RESERVED_ROLE_NAMES - %w[admin user] User.select(:id, :uid, :name, :email, :social_uid, :language, :role_id) + .joins(:role) + .where.not(roles: { name: filtered_roles_names }, deleted: true) .find_each(start: start, finish: stop, batch_size: COMMON[:batch_size]) do |u| - params = { user: { name: u.name, email: u.email, external_id: u.social_uid, language: u.language, role: u.role.name } } + role_name = infer_role_name(u.role.name) + params = { user: { name: u.name, email: u.email, external_id: u.social_uid, language: u.language, role: role_name } } response = Net::HTTP.post(uri('users'), payload(params), COMMON[:headers]) case response @@ -111,4 +116,8 @@ namespace :migrations do [start, stop] end + + def infer_role_name(name) + DEFAULT_ROLES_MAP[name] || name.capitalize + end end From 8d78d898d9b3aa176f0f004cab53e02820696323 Mon Sep 17 00:00:00 2001 From: Samuel Couillard <43917914+scouillard@users.noreply.github.com> Date: Fri, 28 Oct 2022 11:02:55 -0400 Subject: [PATCH 05/37] Resources migration: Added `migrations:rooms` task (#4013) * Initial commit * Fix path * Add owner_email and owner_provider attributes * Add to_datetime to last_session * Add range to rooms migration * quickfix * Change user to owner and add id to Room select * Revert last commit --- lib/tasks/migrations/migrations.rake | 37 ++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/lib/tasks/migrations/migrations.rake b/lib/tasks/migrations/migrations.rake index 4c9c9f214e..3c97dc467a 100644 --- a/lib/tasks/migrations/migrations.rake +++ b/lib/tasks/migrations/migrations.rake @@ -74,6 +74,43 @@ namespace :migrations do exit has_encountred_issue end + task :rooms, [:start, :stop] => :environment do |_task, args| + start, stop = range(args) + has_encountred_issue = 0 + + Room.select(:id, :uid, :name, :bbb_id, :last_session, :user_id) + .find_each(start: start, finish: stop, batch_size: COMMON[:batch_size]).each do |r| + params = { room: { friendly_id: r.uid, + name: r.name, + meeting_id: r.bbb_id, + last_session: r.last_session&.to_datetime, + owner_email: r.owner.email } } + response = Net::HTTP.post(uri('rooms'), payload(params), COMMON[:headers]) + + case response + when Net::HTTPCreated + puts green "Succesfully migrated Room:" + puts cyan " UID: #{r.uid}" + puts cyan " Name: #{r.name}" + else + puts red "Unable to migrate Room:" + puts yellow " UID: #{r.uid}" + puts yellow " Name: #{r.name}" + has_encountred_issue = 1 # At least one of the migrations failed. + end + end + + puts + puts green "Rooms migration completed." + + unless has_encountred_issue.zero? + puts yellow "In case of an error please retry the process to resolve." + puts yellow "If you have not migrated your users, kindly run 'rake migrations:users' first and then retry." + end + + exit has_encountred_issue + end + private def encrypt_params(params) From 7b2493480a9a1d8eb4c699aa58b90e74fa73e63a Mon Sep 17 00:00:00 2001 From: Samuel Couillard <43917914+scouillard@users.noreply.github.com> Date: Fri, 28 Oct 2022 16:25:33 -0400 Subject: [PATCH 06/37] Improve Room migration query (#4046) --- lib/tasks/migrations/migrations.rake | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/lib/tasks/migrations/migrations.rake b/lib/tasks/migrations/migrations.rake index 3c97dc467a..f9779a0574 100644 --- a/lib/tasks/migrations/migrations.rake +++ b/lib/tasks/migrations/migrations.rake @@ -76,10 +76,15 @@ namespace :migrations do task :rooms, [:start, :stop] => :environment do |_task, args| start, stop = range(args) + has_encountred_issue = 0 + filtered_roles_names = Role::RESERVED_ROLE_NAMES - %w[admin user] + filtered_roles_ids = Role.where(name: filtered_roles_names).pluck(:id).uniq Room.select(:id, :uid, :name, :bbb_id, :last_session, :user_id) - .find_each(start: start, finish: stop, batch_size: COMMON[:batch_size]).each do |r| + .joins(:owner) + .where.not(users: { role_id: filtered_roles_ids }) + .find_each(start: start, finish: stop, batch_size: COMMON[:batch_size]) do |r| params = { room: { friendly_id: r.uid, name: r.name, meeting_id: r.bbb_id, From d19c3d5af71e2a332044f610cf6c2b3fecc37830 Mon Sep 17 00:00:00 2001 From: Samuel Couillard <43917914+scouillard@users.noreply.github.com> Date: Mon, 31 Oct 2022 09:52:54 -0400 Subject: [PATCH 07/37] Fix error (#4050) --- lib/tasks/migrations/migrations.rake | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/lib/tasks/migrations/migrations.rake b/lib/tasks/migrations/migrations.rake index f9779a0574..d012f95ce2 100644 --- a/lib/tasks/migrations/migrations.rake +++ b/lib/tasks/migrations/migrations.rake @@ -38,13 +38,11 @@ namespace :migrations do task :users, [:start, :stop] => :environment do |_task, args| start, stop = range(args) - has_encountred_issue = 0 - filtered_roles_names = Role::RESERVED_ROLE_NAMES - %w[admin user] User.select(:id, :uid, :name, :email, :social_uid, :language, :role_id) .joins(:role) - .where.not(roles: { name: filtered_roles_names }, deleted: true) + .where.not(roles: { name: %w[super_admin pending denied] }, deleted: true) .find_each(start: start, finish: stop, batch_size: COMMON[:batch_size]) do |u| role_name = infer_role_name(u.role.name) params = { user: { name: u.name, email: u.email, external_id: u.social_uid, language: u.language, role: role_name } } @@ -76,14 +74,13 @@ namespace :migrations do task :rooms, [:start, :stop] => :environment do |_task, args| start, stop = range(args) - has_encountred_issue = 0 - filtered_roles_names = Role::RESERVED_ROLE_NAMES - %w[admin user] - filtered_roles_ids = Role.where(name: filtered_roles_names).pluck(:id).uniq + + filtered_roles_ids = Role.where(name: %w[super_admin pending denied]).pluck(:id).uniq Room.select(:id, :uid, :name, :bbb_id, :last_session, :user_id) .joins(:owner) - .where.not(users: { role_id: filtered_roles_ids }) + .where.not(users: { role_id: filtered_roles_ids, deleted: true }) .find_each(start: start, finish: stop, batch_size: COMMON[:batch_size]) do |r| params = { room: { friendly_id: r.uid, name: r.name, From 5e7830b888614d645646eb9bec2843fc3330989b Mon Sep 17 00:00:00 2001 From: Khemissi Amir Date: Mon, 31 Oct 2022 14:53:05 +0100 Subject: [PATCH 08/37] V2 resources migration: Removed the use of `Rails.configuration` in tasks. (#4048) Co-authored-by: Ahmad Farhat --- config/application.rb | 4 ---- lib/tasks/migrations/migrations.rake | 14 ++++++-------- 2 files changed, 6 insertions(+), 12 deletions(-) diff --git a/config/application.rb b/config/application.rb index c678a12fe8..d23746fd7a 100644 --- a/config/application.rb +++ b/config/application.rb @@ -51,10 +51,6 @@ def parse_bool(val, default = false) # The default callback url that bn launcher will redirect to config.gl_callback_url = ENV["GL_CALLBACK_URL"] - # Greenlight V3 variables: - config.v3_endpoint = ENV["V3_ENDPOINT"] - config.v3_secret_key_base = ENV["V3_SECRET_KEY_BASE"] - # Default credentials (test-install.blindsidenetworks.com/bigbluebutton). config.bigbluebutton_endpoint_default = "http://test-install.blindsidenetworks.com/bigbluebutton/api/" config.bigbluebutton_secret_default = "8cd8ef52e8e101574e400365b55e11a6" diff --git a/lib/tasks/migrations/migrations.rake b/lib/tasks/migrations/migrations.rake index d012f95ce2..bced060d57 100644 --- a/lib/tasks/migrations/migrations.rake +++ b/lib/tasks/migrations/migrations.rake @@ -4,7 +4,7 @@ namespace :migrations do DEFAULT_ROLES_MAP = { "admin" => "Administrator", "user" => "User" }.freeze COMMON = { headers: { "Content-Type" => "application/json" }, - batch_size: 1000, + batch_size: 500, }.freeze desc "Migrates v2 resources to v3" @@ -116,25 +116,23 @@ namespace :migrations do private def encrypt_params(params) - unless Rails.configuration.v3_secret_key_base.present? + unless ENV["V3_SECRET_KEY_BASE"].present? raise red 'Unable to migrate: No "V3_SECRET_KEY_BASE" provided, please check your .env file.' end - unless Rails.configuration.v3_secret_key_base.size >= 32 + unless ENV["V3_SECRET_KEY_BASE"].size >= 32 raise red 'Unable to migrate: Provided "V3_SECRET_KEY_BASE" must be at least 32 charchters in length.' end - key = Rails.configuration.v3_secret_key_base[0..31] + key = ENV["V3_SECRET_KEY_BASE"][0..31] crypt = ActiveSupport::MessageEncryptor.new(key, cipher: 'aes-256-gcm', serializer: Marshal) crypt.encrypt_and_sign(params, expires_in: 10.seconds) end def uri(path) - unless Rails.configuration.v3_endpoint.present? - raise red 'Unable to migrate: No "V3_ENDPOINT" provided, please check your .env file.' - end + raise red 'Unable to migrate: No "V3_ENDPOINT" provided, please check your .env file.' unless ENV["V3_ENDPOINT"].present? - res = URI(Rails.configuration.v3_endpoint) + res = URI(ENV["V3_ENDPOINT"]) res.path = "/api/v1/migrations/#{path}.json" res end From 893a09c708adc6a97dedb028ae5dfbde1a2f5d2b Mon Sep 17 00:00:00 2001 From: Khemissi Amir Date: Mon, 7 Nov 2022 16:08:49 +0100 Subject: [PATCH 09/37] V2 resources migration: Solved N+1 problem on tasks and unscoped queries. (#4074) --- lib/tasks/migrations/migrations.rake | 26 +++++++++++++++++--------- 1 file changed, 17 insertions(+), 9 deletions(-) diff --git a/lib/tasks/migrations/migrations.rake b/lib/tasks/migrations/migrations.rake index bced060d57..30bd86daab 100644 --- a/lib/tasks/migrations/migrations.rake +++ b/lib/tasks/migrations/migrations.rake @@ -5,14 +5,17 @@ namespace :migrations do COMMON = { headers: { "Content-Type" => "application/json" }, batch_size: 500, + filtered_roles: %w[super_admin admin pending denied user], + filtered_user_roles: %w[super_admin pending denied] }.freeze desc "Migrates v2 resources to v3" task :roles, [] => :environment do |_task, _args| has_encountred_issue = 0 - Role.select(:id, :name) - .where.not(name: Role::RESERVED_ROLE_NAMES) + Role.unscoped + .select(:id, :name) + .where.not(name: COMMON[:filtered_roles]) .find_each(batch_size: COMMON[:batch_size]) do |r| params = { role: { name: r.name.capitalize } } response = Net::HTTP.post(uri('roles'), payload(params), COMMON[:headers]) @@ -40,9 +43,10 @@ namespace :migrations do start, stop = range(args) has_encountred_issue = 0 - User.select(:id, :uid, :name, :email, :social_uid, :language, :role_id) - .joins(:role) - .where.not(roles: { name: %w[super_admin pending denied] }, deleted: true) + User.unscoped + .select(:id, :uid, :name, :email, :social_uid, :language, :role_id) + .includes(:role) + .where.not(roles: { name: COMMON[:filtered_user_roles] }, deleted: true) .find_each(start: start, finish: stop, batch_size: COMMON[:batch_size]) do |u| role_name = infer_role_name(u.role.name) params = { user: { name: u.name, email: u.email, external_id: u.social_uid, language: u.language, role: role_name } } @@ -76,11 +80,15 @@ namespace :migrations do start, stop = range(args) has_encountred_issue = 0 - filtered_roles_ids = Role.where(name: %w[super_admin pending denied]).pluck(:id).uniq + filtered_roles_ids = Role.unscoped + .select(:id, :name) + .where(name: COMMON[:filtered_user_roles]) + .pluck(:id) - Room.select(:id, :uid, :name, :bbb_id, :last_session, :user_id) - .joins(:owner) - .where.not(users: { role_id: filtered_roles_ids, deleted: true }) + Room.unscoped + .select(:id, :uid, :name, :bbb_id, :last_session, :user_id) + .includes(:owner) + .where.not(users: { role_id: filtered_roles_ids, deleted: true }, deleted: true) .find_each(start: start, finish: stop, batch_size: COMMON[:batch_size]) do |r| params = { room: { friendly_id: r.uid, name: r.name, From c5443ff1298997c3333dad7e1d1f6925d82670e0 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 5 Jan 2023 13:50:47 -0500 Subject: [PATCH 10/37] Bump rails-html-sanitizer from 1.4.3 to 1.4.4 (#4264) Bumps [rails-html-sanitizer](https://github.com/rails/rails-html-sanitizer) from 1.4.3 to 1.4.4. - [Release notes](https://github.com/rails/rails-html-sanitizer/releases) - [Changelog](https://github.com/rails/rails-html-sanitizer/blob/master/CHANGELOG.md) - [Commits](https://github.com/rails/rails-html-sanitizer/compare/v1.4.3...v1.4.4) --- updated-dependencies: - dependency-name: rails-html-sanitizer dependency-type: indirect ... Signed-off-by: dependabot[bot] Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- Gemfile.lock | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/Gemfile.lock b/Gemfile.lock index 28fab3151b..61f03a74f8 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -220,7 +220,7 @@ GEM activesupport (>= 4) railties (>= 4) request_store (~> 1.0) - loofah (2.18.0) + loofah (2.19.1) crass (~> 1.0.2) nokogiri (>= 1.5.9) mail (2.7.1) @@ -237,7 +237,7 @@ GEM multipart-post (2.1.1) net-ldap (0.17.0) nio4r (2.5.8) - nokogiri (1.13.7) + nokogiri (1.13.10) mini_portile2 (~> 2.8.0) racc (~> 1.4) oauth (0.5.10) @@ -301,7 +301,7 @@ GEM public_suffix (4.0.7) puma (4.3.12) nio4r (~> 2.0) - racc (1.6.0) + racc (1.6.1) rack (2.2.4) rack-oauth2 (1.21.2) activesupport @@ -333,8 +333,8 @@ GEM rails-dom-testing (2.0.3) activesupport (>= 4.2.0) nokogiri (>= 1.6) - rails-html-sanitizer (1.4.3) - loofah (~> 2.3) + rails-html-sanitizer (1.4.4) + loofah (~> 2.19, >= 2.19.1) railties (5.2.8.1) actionpack (= 5.2.8.1) activesupport (= 5.2.8.1) From d0a3658ddb3a6b7043824f8dc49705c9ced442e3 Mon Sep 17 00:00:00 2001 From: Jesus Federico Date: Thu, 5 Jan 2023 19:58:47 +0100 Subject: [PATCH 11/37] fix: Gemfile & Gemfile.lock to reduce vulnerabilities (#4023) The following vulnerabilities are fixed with an upgrade: - https://snyk.io/vuln/SNYK-RUBY-RACK-1061917 Co-authored-by: snyk-bot Co-authored-by: Ahmad Farhat --- Gemfile | 2 +- Gemfile.lock | 73 +++++++++++++++++++++++++++++++++------------------- 2 files changed, 47 insertions(+), 28 deletions(-) diff --git a/Gemfile b/Gemfile index 10e3aabc84..1991b3dfd2 100644 --- a/Gemfile +++ b/Gemfile @@ -10,7 +10,7 @@ end # Bundle edge Rails instead: gem 'rails', github: 'rails/rails' gem 'aws-sdk-s3', '~> 1.88.1' gem 'bcrypt', '~> 3.1.7' -gem 'bigbluebutton-api-ruby', '~> 1.9' +gem 'bigbluebutton-api-ruby', '~> 1.9', '>= 1.9.0' gem 'bn-ldap-authentication', '~> 0.1.4' gem 'bootsnap', '~> 1.7.2', require: false gem 'bootstrap', '~> 4.3.1' diff --git a/Gemfile.lock b/Gemfile.lock index 61f03a74f8..0d47c13fa8 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -52,8 +52,8 @@ GEM i18n (>= 0.7, < 2) minitest (~> 5.1) tzinfo (~> 1.1) - addressable (2.8.0) - public_suffix (>= 2.0.2, < 5.0) + addressable (2.8.1) + public_suffix (>= 2.0.2, < 6.0) aes_key_wrap (1.1.0) arel (9.0.0) ast (2.4.2) @@ -85,7 +85,7 @@ GEM rack (>= 1.6.11) rubyzip (>= 1.3.0) xml-simple (~> 1.1) - bindata (2.4.10) + bindata (2.4.13) bindex (0.8.1) bn-ldap-authentication (0.1.4) net-ldap (~> 0) @@ -114,11 +114,11 @@ GEM digest-crc (0.6.4) rake (>= 12.0.0, < 14.0.0) docile (1.4.0) - dotenv (2.7.6) - dotenv-rails (2.7.6) - dotenv (= 2.7.6) + dotenv (2.8.1) + dotenv-rails (2.8.1) + dotenv (= 2.8.1) railties (>= 3.2) - erubi (1.10.0) + erubi (1.11.0) execjs (2.8.1) factory_bot (6.2.1) activesupport (>= 5.0.0) @@ -127,7 +127,7 @@ GEM railties (>= 5.0.0) faker (2.21.0) i18n (>= 1.8.11, < 2) - faraday (1.10.0) + faraday (1.10.2) faraday-em_http (~> 1.0) faraday-em_synchrony (~> 1.0) faraday-excon (~> 1.1) @@ -143,8 +143,8 @@ GEM faraday-em_synchrony (1.0.0) faraday-excon (1.1.0) faraday-httpclient (1.0.1) - faraday-multipart (1.0.3) - multipart-post (>= 1.2, < 3) + faraday-multipart (1.0.4) + multipart-post (~> 2) faraday-net_http (1.0.1) faraday-net_http_persistent (1.2.0) faraday-patron (1.0.0) @@ -206,11 +206,12 @@ GEM railties (>= 4.2.0) thor (>= 0.14, < 2.0) json (2.6.2) - json-jwt (1.14.0) + json-jwt (1.15.3) activesupport (>= 4.2) aes_key_wrap bindata - jwt (2.3.0) + httpclient + jwt (2.5.0) listen (3.7.1) rb-fsevent (~> 0.10, >= 0.10.3) rb-inotify (~> 0.9, >= 0.9.10) @@ -230,23 +231,32 @@ GEM method_source (1.0.0) mini_mime (1.1.2) mini_portile2 (2.8.0) - minitest (5.16.2) + minitest (5.16.3) msgpack (1.5.1) multi_json (1.15.0) multi_xml (0.6.0) - multipart-post (2.1.1) + multipart-post (2.2.3) net-ldap (0.17.0) + net-protocol (0.1.3) + timeout + net-smtp (0.3.2) + net-protocol nio4r (2.5.8) nokogiri (1.13.10) mini_portile2 (~> 2.8.0) racc (~> 1.4) - oauth (0.5.10) - oauth2 (1.4.9) + oauth (1.1.0) + oauth-tty (~> 1.0, >= 1.0.1) + snaky_hash (~> 2.0) + version_gem (~> 1.1) + oauth-tty (1.0.5) + version_gem (~> 1.1, >= 1.1.1) + oauth2 (1.4.11) faraday (>= 0.17.3, < 3.0) jwt (>= 1.0, < 3.0) multi_json (~> 1.3) multi_xml (~> 0.5) - rack (>= 1.2, < 3) + rack (>= 1.2, < 4) omniauth (2.1.0) hashie (>= 3.4.6) rack (>= 2.2.3) @@ -278,16 +288,17 @@ GEM addressable (~> 2.5) omniauth (>= 1.9, < 3) openid_connect (~> 1.1) - openid_connect (1.3.0) + openid_connect (1.4.2) activemodel attr_required (>= 1.0.0) - json-jwt (>= 1.5.0) - rack-oauth2 (>= 1.6.1) - swd (>= 1.0.0) + json-jwt (>= 1.15.0) + net-smtp + rack-oauth2 (~> 1.21) + swd (~> 1.3) tzinfo validate_email validate_url - webfinger (>= 1.0.1) + webfinger (~> 1.2) os (1.1.4) pagy (3.11.0) parallel (1.22.1) @@ -297,19 +308,19 @@ GEM pluck_to_hash (1.0.2) activerecord (>= 4.0.2) activesupport (>= 4.0.2) - popper_js (1.16.0) - public_suffix (4.0.7) + popper_js (1.16.1) + public_suffix (5.0.0) puma (4.3.12) nio4r (~> 2.0) racc (1.6.1) rack (2.2.4) - rack-oauth2 (1.21.2) + rack-oauth2 (1.21.3) activesupport attr_required httpclient json-jwt (>= 1.11.0) rack (>= 2.1.0) - rack-protection (2.2.1) + rack-protection (3.0.2) rack rack-test (2.0.2) rack (>= 1.3) @@ -415,6 +426,9 @@ GEM json (>= 1.8, < 3) simplecov-html (~> 0.10.0) simplecov-html (0.10.2) + snaky_hash (2.0.1) + hashie + version_gem (~> 1.1, >= 1.1.1) spring (2.1.1) spring-watcher-listen (2.0.1) listen (>= 2.7, < 4.0) @@ -438,6 +452,7 @@ GEM thor (1.2.1) thread_safe (0.3.6) tilt (2.0.11) + timeout (0.3.0) tins (1.31.1) sync trailblazer-option (0.1.2) @@ -458,6 +473,7 @@ GEM validate_url (1.0.15) activemodel (>= 3.0.0) public_suffix + version_gem (1.1.1) web-console (3.7.0) actionview (>= 5.0) activemodel (>= 5.0) @@ -484,7 +500,7 @@ DEPENDENCIES action-cable-testing (~> 0.6, >= 0.6.1) aws-sdk-s3 (~> 1.88.1) bcrypt (~> 3.1.7) - bigbluebutton-api-ruby (~> 1.9) + bigbluebutton-api-ruby (~> 1.9, >= 1.9.0) bn-ldap-authentication (~> 0.1.4) bootsnap (~> 1.7.2) bootstrap (~> 4.3.1) @@ -539,3 +555,6 @@ DEPENDENCIES uglifier (~> 4.2.0) web-console (~> 3.7, >= 3.7.0) webmock (~> 3.11) + +BUNDLED WITH + 2.1.4 From 4085800c5f8f5fc037e1856ac8a9374e4e11000a Mon Sep 17 00:00:00 2001 From: Ahmad Farhat Date: Thu, 5 Jan 2023 14:34:08 -0500 Subject: [PATCH 12/37] Added guest=true for all users not signed in (#4414) * Added guest=true for all users not signed in * Rubo --- Gemfile.lock | 3 --- app/controllers/concerns/bbb_server.rb | 1 + app/controllers/concerns/joiner.rb | 1 + spec/controllers/rooms_controller_spec.rb | 11 +++++++---- 4 files changed, 9 insertions(+), 7 deletions(-) diff --git a/Gemfile.lock b/Gemfile.lock index 0d47c13fa8..34dcfda0c6 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -555,6 +555,3 @@ DEPENDENCIES uglifier (~> 4.2.0) web-console (~> 3.7, >= 3.7.0) webmock (~> 3.11) - -BUNDLED WITH - 2.1.4 diff --git a/app/controllers/concerns/bbb_server.rb b/app/controllers/concerns/bbb_server.rb index 26d9ea2d46..8f84544881 100644 --- a/app/controllers/concerns/bbb_server.rb +++ b/app/controllers/concerns/bbb_server.rb @@ -56,6 +56,7 @@ def join_path(room, name, options = {}, uid = nil) join_opts[:join_via_html5] = true join_opts[:avatarURL] = options[:avatarURL] if options[:avatarURL].present? join_opts[:createTime] = room.last_session.to_datetime.strftime("%Q") if room.last_session + join_opts[:guest] = true if options[:guest] bbb_server.join_meeting_url(room.bbb_id, name, password, join_opts) end diff --git a/app/controllers/concerns/joiner.rb b/app/controllers/concerns/joiner.rb index f887ed43ec..9d51ae1d84 100644 --- a/app/controllers/concerns/joiner.rb +++ b/app/controllers/concerns/joiner.rb @@ -68,6 +68,7 @@ def join_room(opts) opts[:record] = record_meeting opts[:require_moderator_approval] = room_setting_with_config("requireModeratorApproval") opts[:mute_on_start] = room_setting_with_config("muteOnStart") + opts[:guest] = current_user.nil? if current_user redirect_to join_path(@room, current_user.name, opts, current_user.uid) diff --git a/spec/controllers/rooms_controller_spec.rb b/spec/controllers/rooms_controller_spec.rb index 58131c0b31..ecea8272d8 100644 --- a/spec/controllers/rooms_controller_spec.rb +++ b/spec/controllers/rooms_controller_spec.rb @@ -270,7 +270,7 @@ def random_valid_room_params allow_any_instance_of(BigBlueButton::BigBlueButtonApi).to receive(:is_meeting_running?).and_return(true) post :join, params: { room_uid: @room, join_name: "Join Name" } - expect(response).to redirect_to(join_path(@owner.main_room, "Join Name", {}, response.cookies["guest_id"])) + expect(response).to redirect_to(join_path(@owner.main_room, "Join Name", { guest: true }, response.cookies["guest_id"])) end it "should use join name if user is not logged in and meeting running and moderator access code is enabled and set" do @@ -286,7 +286,8 @@ def random_valid_room_params post :join, params: { room_uid: room, join_name: "Join Name" }, session: { moderator_access_code: "abcdef" } - expect(response).to redirect_to(join_path(room, "Join Name", { user_is_moderator: true }, response.cookies["guest_id"])) + expect(response).to redirect_to(join_path(room, "Join Name", { user_is_moderator: true, guest: true }, +response.cookies["guest_id"])) end it "should render wait if meeting isn't running" do @@ -427,7 +428,8 @@ def random_valid_room_params post :join, params: { room_uid: room, join_name: "Join Name" }, session: { moderator_access_code: "abcdef" } - expect(response).to redirect_to(join_path(room, "Join Name", { user_is_moderator: true }, response.cookies["guest_id"])) + expect(response).to redirect_to(join_path(room, "Join Name", { user_is_moderator: true, guest: true }, +response.cookies["guest_id"])) end it "should join the room as moderator if the user has the moderator_access code (and regular access code is set)" do @@ -443,7 +445,8 @@ def random_valid_room_params post :join, params: { room_uid: room, join_name: "Join Name" }, session: { moderator_access_code: "abcdef" } - expect(response).to redirect_to(join_path(room, "Join Name", { user_is_moderator: true }, response.cookies["guest_id"])) + expect(response).to redirect_to(join_path(room, "Join Name", { user_is_moderator: true, guest: true }, +response.cookies["guest_id"])) end it "should redirect to login if a wrong moderator access code is supplied" do From a836266e890b365c3e3d9f84531d520fbd021fde Mon Sep 17 00:00:00 2001 From: "transifex-integration[bot]" <43880903+transifex-integration[bot]@users.noreply.github.com> Date: Thu, 5 Jan 2023 14:40:13 -0500 Subject: [PATCH 13/37] Translate /config/locales/en.yml in ru (#3856) translation completed for the source file '/config/locales/en.yml' on the 'ru' language. Co-authored-by: transifex-integration[bot] <43880903+transifex-integration[bot]@users.noreply.github.com> --- config/locales/ru.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/config/locales/ru.yml b/config/locales/ru.yml index 175d27dc6f..4efb8a5256 100644 --- a/config/locales/ru.yml +++ b/config/locales/ru.yml @@ -335,7 +335,7 @@ ru: search: start: Искать... landing: - about: "%{href} это упрощенный веб интерфейс для вашего сервера веб конференций открытым исходным кодом BigBlueButton. Вы можете создавать свои собственные комнаты для проведения встреч или присоединяться к другим, используя короткую и удобную ссылку." + about: "%{href} — это простой веб-интерфейс для сервера веб-конференций с открытым исходным кодом BigBlueButton. Вы можете создавать свои собственные комнаты для проведения встреч или присоединяться к другим, используя короткую и удобную ссылку." welcome: Добро пожаловать в BigBlueButton. video: Ознакомьтесь с нашим учебником по использованию Greenlight upgrade: "Покажите мне, как обновить до 2.0!" @@ -681,3 +681,5 @@ ru: signin: Пожалуйста войдте для доступа к Вашему аккаунту. title: Подтвердите Ваш электронный адрес email verification: Проверка + session: + expired: "Время сеанса истекло, пожалуйста, войдите в систему повторно." From a17e2553b8fca17c33e6a88ab5727b496d2c2c3b Mon Sep 17 00:00:00 2001 From: "transifex-integration[bot]" <43880903+transifex-integration[bot]@users.noreply.github.com> Date: Thu, 5 Jan 2023 14:40:23 -0500 Subject: [PATCH 14/37] Translate /config/locales/en.yml in hu_HU (#3850) translation completed for the source file '/config/locales/en.yml' on the 'hu_HU' language. Co-authored-by: transifex-integration[bot] <43880903+transifex-integration[bot]@users.noreply.github.com> --- config/locales/hu_HU.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/config/locales/hu_HU.yml b/config/locales/hu_HU.yml index 7a75bdda79..a0528c2c0a 100644 --- a/config/locales/hu_HU.yml +++ b/config/locales/hu_HU.yml @@ -683,3 +683,5 @@ hu_HU: signin: A fiókod eléréséhez jelentkezz be. title: Ellenőrizd a postaládádat verification: Visszaigazolás + session: + expired: Munkameneted lejárt (jelentkezz be újra). From c1573809d9583540107a4a04013158c2fd0aeebd Mon Sep 17 00:00:00 2001 From: Etopian Inc Date: Fri, 6 Jan 2023 00:41:08 +0500 Subject: [PATCH 15/37] Fix time formatting in Arabic and Iraqi Arabic locales (#4055) * Fix locale time formatting in Arabic. The time formatting in Arabic is broken and it causes a 500 error on the room page if a user switches to Arabic. * Time formatting in Iraqi Arabic is broken Time formatting in Iraqi Arabic is broken, it causes a 500 error on the room page if a user tries to switch their language to it.. Co-authored-by: Ahmad Farhat --- config/locales/ar.yml | 2 +- config/locales/ar_IQ.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/config/locales/ar.yml b/config/locales/ar.yml index 8258fb76b2..649bbc0b08 100644 --- a/config/locales/ar.yml +++ b/config/locales/ar.yml @@ -669,7 +669,7 @@ ar: يستخدم هذا النشر خادم اختبار تمت تهيئته مسبقًا ، ويجب استبداله بخادمك الشخصي. لمزيد من التفاصيل ، اطلع على%{href} . time: formats: - default: "b %d, %Y %-I:%M%P%" + default: "%b %d, %Y %-I:%M%P" update: تحديث verify: accept: تحقق diff --git a/config/locales/ar_IQ.yml b/config/locales/ar_IQ.yml index 0ae97b3057..7406f2e323 100644 --- a/config/locales/ar_IQ.yml +++ b/config/locales/ar_IQ.yml @@ -669,7 +669,7 @@ ar_IQ: يستخدم هذا النشر خادم اختبار تمت تهيئته مسبقًا ، ويجب استبداله بخادمك الشخصي. لمزيد من التفاصيل ، اطلع على%{href} . time: formats: - default: "b %d, %Y %-I:%M%P%" + default: "%b %d, %Y %-I:%M%P" update: تحديث verify: accept: تحقق From 89f9f6a82a2fa5765fa0a198383049177f9f25e0 Mon Sep 17 00:00:00 2001 From: Samuel Couillard <43917914+scouillard@users.noreply.github.com> Date: Mon, 16 Jan 2023 09:48:49 -0500 Subject: [PATCH 16/37] Migration upgrade (V2): addition of RolePermissions, RoomSettings, SharedAccess, SiteSettings, RoomConfiguration data (#4339) * Add SiteSettings and RoomConfigs to migration * Create standalone task for Room Settings * Quickfixes * Quickfix * Rubo * Add JSON parse * Fix RoomSettings data structure * Remove default values from room_settings hash * Put RoomSettings logicin Room task * Add SharedAccess task * Fix SharedAccess logs * Fix SiteSettings task * Fix registration method * Add RolePermissions to Role task * Move SharedAccess to Room, fix SiteSettings * Fix SharedAccess * Add RoomsConfiguration * Fix Roles after test * Rename SiteSettings to Settings * Rubocop * Add logic to bypass HomeRoom empty string * fix typos * Rubocop * Remove PrimaryColorDark from settings data --- lib/tasks/migrations/migrations.rake | 192 ++++++++++++++++++++------- 1 file changed, 143 insertions(+), 49 deletions(-) diff --git a/lib/tasks/migrations/migrations.rake b/lib/tasks/migrations/migrations.rake index 30bd86daab..8d9dd6c7c9 100644 --- a/lib/tasks/migrations/migrations.rake +++ b/lib/tasks/migrations/migrations.rake @@ -17,20 +17,36 @@ namespace :migrations do .select(:id, :name) .where.not(name: COMMON[:filtered_roles]) .find_each(batch_size: COMMON[:batch_size]) do |r| - params = { role: { name: r.name.capitalize } } - response = Net::HTTP.post(uri('roles'), payload(params), COMMON[:headers]) - - case response - when Net::HTTPCreated - puts green "Succesfully migrated Role:" - puts cyan " ID: #{r.id}" - puts cyan " Name: #{params[:role][:name]}" - else - puts red "Unable to migrate Role:" - puts yellow " ID: #{r.id}" - puts yellow " Name: #{params[:role][:name]}" - has_encountred_issue = 1 # At least one of the migrations failed. - end + # RolePermissions + role_permissions_hash = RolePermission.where(role_id: r.id).pluck(:name, :value).to_h + # Returns nil if the RolePermission value is the same as the corresponding default value in V3 + role_permissions = { + CreateRoom: role_permissions_hash['can_create_rooms'] == "true" ? nil : "false", + CanRecord: role_permissions_hash['can_launch_recording'] == "true" ? nil : "false", + ManageUsers: role_permissions_hash['can_manage_users'] == "false" ? nil : "true", + ManageRoles: role_permissions_hash['can_edit_roles'] == "false" ? nil : "true", + # In V3, can_manage_room_recordings is split into two distinct permissions: ManageRooms and ManageRecordings + ManageRooms: role_permissions_hash['can_manage_rooms_recordings'] == "false" ? nil : "true", + ManageRecordings: role_permissions_hash['can_manage_room_recordings'] == "false" ? nil : "true", + ManageSiteSettings: role_permissions_hash['can_edit_site_settings'] == "false" ? nil : "true" + }.compact + + params = { role: { name: r.name.capitalize, + role_permissions: role_permissions } } + + response = Net::HTTP.post(uri('roles'), payload(params), COMMON[:headers]) + + case response + when Net::HTTPCreated + puts green "Succesfully migrated Role:" + puts cyan " ID: #{r.id}" + puts cyan " Name: #{params[:role][:name]}" + else + puts red "Unable to migrate Role:" + puts yellow " ID: #{r.id}" + puts yellow " Name: #{params[:role][:name]}" + has_encountred_issue = 1 # At least one of the migrations failed. + end end puts @@ -48,21 +64,22 @@ namespace :migrations do .includes(:role) .where.not(roles: { name: COMMON[:filtered_user_roles] }, deleted: true) .find_each(start: start, finish: stop, batch_size: COMMON[:batch_size]) do |u| - role_name = infer_role_name(u.role.name) - params = { user: { name: u.name, email: u.email, external_id: u.social_uid, language: u.language, role: role_name } } - response = Net::HTTP.post(uri('users'), payload(params), COMMON[:headers]) - - case response - when Net::HTTPCreated - puts green "Succesfully migrated User:" - puts cyan " UID: #{u.uid}" - puts cyan " Name: #{params[:user][:name]}" - else - puts red "Unable to migrate User:" - puts yellow " UID: #{u.uid}" - puts yellow " Name: #{params[:user][:name]}" - has_encountred_issue = 1 # At least one of the migrations failed. - end + role_name = infer_role_name(u.role.name) + params = { user: { name: u.name, email: u.email, external_id: u.social_uid, language: u.language, role: role_name } } + + response = Net::HTTP.post(uri('users'), payload(params), COMMON[:headers]) + + case response + when Net::HTTPCreated + puts green "Succesfully migrated User:" + puts cyan " UID: #{u.uid}" + puts cyan " Name: #{params[:user][:name]}" + else + puts red "Unable to migrate User:" + puts yellow " UID: #{u.uid}" + puts yellow " Name: #{params[:user][:name]}" + has_encountred_issue = 1 # At least one of the migrations failed. + end end puts @@ -85,29 +102,48 @@ namespace :migrations do .where(name: COMMON[:filtered_user_roles]) .pluck(:id) - Room.unscoped - .select(:id, :uid, :name, :bbb_id, :last_session, :user_id) + Room.unscoped.select(:id, :uid, :name, :bbb_id, :last_session, :user_id, :room_settings) .includes(:owner) .where.not(users: { role_id: filtered_roles_ids, deleted: true }, deleted: true) .find_each(start: start, finish: stop, batch_size: COMMON[:batch_size]) do |r| - params = { room: { friendly_id: r.uid, - name: r.name, - meeting_id: r.bbb_id, - last_session: r.last_session&.to_datetime, - owner_email: r.owner.email } } - response = Net::HTTP.post(uri('rooms'), payload(params), COMMON[:headers]) - - case response - when Net::HTTPCreated - puts green "Succesfully migrated Room:" - puts cyan " UID: #{r.uid}" - puts cyan " Name: #{r.name}" - else - puts red "Unable to migrate Room:" - puts yellow " UID: #{r.uid}" - puts yellow " Name: #{r.name}" - has_encountred_issue = 1 # At least one of the migrations failed. - end + # RoomSettings + parsed_room_settings = JSON.parse(r.room_settings) + # Returns nil if the RoomSetting value is the same as the corresponding default value in V3 + room_settings = if parsed_room_settings.empty? # Bypass Home Rome room_settings which is an empty hash by default + {} + else + { + record: parsed_room_settings["recording"] == false ? nil : "true", + muteOnStart: parsed_room_settings["muteOnStart"] == false ? nil : "true", + glAnyoneCanStart: parsed_room_settings["anyoneCanStart"] == false ? nil : "true", + glAnyoneJoinAsModerator: parsed_room_settings["joinModerator"] == false ? nil : "true", + guestPolicy: parsed_room_settings["requireModeratorApproval"] == false ? nil : "ASK_MODERATOR", + }.compact + end + + shared_users_emails = SharedAccess.joins(:user).where(room_id: r.id).pluck(:'users.email') + + params = { room: { friendly_id: r.uid, + name: r.name, + meeting_id: r.bbb_id, + last_session: r.last_session&.to_datetime, + owner_email: r.owner.email, + room_settings: room_settings, + shared_users_emails: shared_users_emails } } + + response = Net::HTTP.post(uri('rooms'), payload(params), COMMON[:headers]) + + case response + when Net::HTTPCreated + puts green "Succesfully migrated Room:" + puts cyan " UID: #{r.uid}" + puts cyan " Name: #{r.name}" + else + puts red "Unable to migrate Room:" + puts yellow " UID: #{r.uid}" + puts yellow " Name: #{r.name}" + has_encountred_issue = 1 # At least one of the migrations failed. + end end puts @@ -121,6 +157,52 @@ namespace :migrations do exit has_encountred_issue end + task settings: :environment do |_task| + has_encountred_issue = 0 + + settings_hash = Setting.find_by(provider: 'greenlight').features.pluck(:name, :value).to_h + + # SiteSettings + site_settings = { + PrimaryColor: settings_hash['Primary Color'], + PrimaryColorLight: settings_hash['Primary Color Lighten'], + Terms: settings_hash['Legal URL'], + PrivacyPolicy: settings_hash['Privacy Policy URL'], + RegistrationMethod: infer_registration_method(settings_hash['Registration Method']), + ShareRooms: settings_hash['Shared Access'], + PreuploadPresentation: settings_hash['Preupload Presentation'], + }.compact + + # RoomConfigurations + room_configurations = { + record: settings_hash['Room Configuration Recording'], + muteOnStart: settings_hash['Room Configuration Mute On Join'], + guestPolicy: settings_hash['Room Configuration Require Moderator'], + glAnyoneCanStart: settings_hash['Room Configuration Allow Any Start'], + glAnyoneJoinAsModerator: settings_hash['Room Configuration All Join Moderator'], + glRequireAuthentication: settings_hash['Room Authentication'] + }.compact + + params = { settings: { site_settings: site_settings, room_configurations: room_configurations } } + + response = Net::HTTP.post(uri('settings'), payload(params), COMMON[:headers]) + + case response + when Net::HTTPCreated + puts green "Successfully migrated Settings" + else + puts red "Unable to migrate Settings" + has_encountred_issue = 1 # At least one of the migrations failed. + end + + puts + puts green "Settings migration completed." + + puts yellow "In case of an error please retry the process to resolve." unless has_encountred_issue.zero? + + exit has_encountred_issue + end + private def encrypt_params(params) @@ -165,4 +247,16 @@ namespace :migrations do def infer_role_name(name) DEFAULT_ROLES_MAP[name] || name.capitalize end + + # Registration Method returns "0", "1" or "2" but V3 expects "open", "invite" or "approval" + def infer_registration_method(registration_method) + case registration_method + when "1" + "invite" + when "2" + "approval" + else + "open" + end + end end From 38a390e8fc88bc2adef5e12740df0b282f5155fb Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 19 Jan 2023 10:08:11 -0500 Subject: [PATCH 17/37] Bump rack from 2.2.4 to 2.2.6.2 (#4541) Bumps [rack](https://github.com/rack/rack) from 2.2.4 to 2.2.6.2. - [Release notes](https://github.com/rack/rack/releases) - [Changelog](https://github.com/rack/rack/blob/main/CHANGELOG.md) - [Commits](https://github.com/rack/rack/compare/2.2.4...v2.2.6.2) --- updated-dependencies: - dependency-name: rack dependency-type: indirect ... Signed-off-by: dependabot[bot] Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- Gemfile.lock | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Gemfile.lock b/Gemfile.lock index 34dcfda0c6..fb6707e8e7 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -313,7 +313,7 @@ GEM puma (4.3.12) nio4r (~> 2.0) racc (1.6.1) - rack (2.2.4) + rack (2.2.6.2) rack-oauth2 (1.21.3) activesupport attr_required From 83bb0a92c3be57055b7118e657b4de92d7fd47f1 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 26 Jan 2023 09:54:01 -0500 Subject: [PATCH 18/37] Bump globalid from 1.0.0 to 1.0.1 (#4543) Bumps [globalid](https://github.com/rails/globalid) from 1.0.0 to 1.0.1. - [Release notes](https://github.com/rails/globalid/releases) - [Commits](https://github.com/rails/globalid/compare/v1.0.0...v1.0.1) --- updated-dependencies: - dependency-name: globalid dependency-type: indirect ... Signed-off-by: dependabot[bot] Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- Gemfile.lock | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Gemfile.lock b/Gemfile.lock index fb6707e8e7..0b428ff3de 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -153,7 +153,7 @@ GEM ffi (1.15.5) font-awesome-sass (5.9.0) sassc (>= 1.11) - globalid (1.0.0) + globalid (1.0.1) activesupport (>= 5.0) google-apis-core (0.5.0) addressable (~> 2.5, >= 2.5.1) @@ -231,7 +231,7 @@ GEM method_source (1.0.0) mini_mime (1.1.2) mini_portile2 (2.8.0) - minitest (5.16.3) + minitest (5.17.0) msgpack (1.5.1) multi_json (1.15.0) multi_xml (0.6.0) From 93d34aad0268f84c6fe32f69df374c985aa38ed0 Mon Sep 17 00:00:00 2001 From: Samuel Couillard <43917914+scouillard@users.noreply.github.com> Date: Tue, 31 Jan 2023 13:48:03 -0500 Subject: [PATCH 19/37] Add Errors Logs to Migration (v2) (#4678) * Add Errors logging to Migration (v2) * Improve error logging * rubo * Fix last line removal mistake --- lib/tasks/migrations/migrations.rake | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/lib/tasks/migrations/migrations.rake b/lib/tasks/migrations/migrations.rake index 8d9dd6c7c9..8ab761e250 100644 --- a/lib/tasks/migrations/migrations.rake +++ b/lib/tasks/migrations/migrations.rake @@ -39,12 +39,13 @@ namespace :migrations do case response when Net::HTTPCreated puts green "Succesfully migrated Role:" - puts cyan " ID: #{r.id}" - puts cyan " Name: #{params[:role][:name]}" + puts cyan "ID: #{r.id}" + puts cyan "Name: #{params[:role][:name]}" else puts red "Unable to migrate Role:" - puts yellow " ID: #{r.id}" - puts yellow " Name: #{params[:role][:name]}" + puts yellow "ID: #{r.id}" + puts yellow "Name: #{params[:role][:name]}" + puts red "Errors: #{JSON.parse(response.body.to_s)['errors']}" has_encountred_issue = 1 # At least one of the migrations failed. end end @@ -76,8 +77,9 @@ namespace :migrations do puts cyan " Name: #{params[:user][:name]}" else puts red "Unable to migrate User:" - puts yellow " UID: #{u.uid}" - puts yellow " Name: #{params[:user][:name]}" + puts yellow "UID: #{u.uid}" + puts yellow "Name: #{params[:user][:name]}" + puts red "Errors: #{JSON.parse(response.body.to_s)['errors']}" has_encountred_issue = 1 # At least one of the migrations failed. end end @@ -136,12 +138,13 @@ namespace :migrations do case response when Net::HTTPCreated puts green "Succesfully migrated Room:" - puts cyan " UID: #{r.uid}" - puts cyan " Name: #{r.name}" + puts cyan "UID: #{r.uid}" + puts cyan "Name: #{r.name}" else puts red "Unable to migrate Room:" - puts yellow " UID: #{r.uid}" - puts yellow " Name: #{r.name}" + puts yellow "UID: #{r.uid}" + puts yellow "Name: #{r.name}" + puts red "Errors: #{JSON.parse(response.body.to_s)['errors']}" has_encountred_issue = 1 # At least one of the migrations failed. end end @@ -192,6 +195,7 @@ namespace :migrations do puts green "Successfully migrated Settings" else puts red "Unable to migrate Settings" + puts red "Errors: #{JSON.parse(response.body.to_s)['errors']}" has_encountred_issue = 1 # At least one of the migrations failed. end From 31337e85940744ceddbb98071ea60a2d1cce0fd3 Mon Sep 17 00:00:00 2001 From: Khemissi Amir Date: Wed, 1 Feb 2023 20:29:34 +0100 Subject: [PATCH 20/37] V3 Migrations: Minor fixes and optimizations to v2 rake tasks. (#4719) * V3 Migrations: Optimized `migrations:roles` task. * V3 Migrations: Fixed `migrations:rooms` task. --- app/models/shared_access.rb | 1 + lib/tasks/migrations/migrations.rake | 36 +++++++++++++++------------- 2 files changed, 20 insertions(+), 17 deletions(-) diff --git a/app/models/shared_access.rb b/app/models/shared_access.rb index eb88a555c0..6451bd42e0 100644 --- a/app/models/shared_access.rb +++ b/app/models/shared_access.rb @@ -2,4 +2,5 @@ class SharedAccess < ApplicationRecord belongs_to :room + belongs_to :user end diff --git a/lib/tasks/migrations/migrations.rake b/lib/tasks/migrations/migrations.rake index 8ab761e250..117d5fdd20 100644 --- a/lib/tasks/migrations/migrations.rake +++ b/lib/tasks/migrations/migrations.rake @@ -1,4 +1,5 @@ # frozen_string_literal: true +# rubocop:disable all namespace :migrations do DEFAULT_ROLES_MAP = { "admin" => "Administrator", "user" => "User" }.freeze @@ -15,21 +16,22 @@ namespace :migrations do Role.unscoped .select(:id, :name) + .includes(:role_permissions) .where.not(name: COMMON[:filtered_roles]) .find_each(batch_size: COMMON[:batch_size]) do |r| # RolePermissions - role_permissions_hash = RolePermission.where(role_id: r.id).pluck(:name, :value).to_h - # Returns nil if the RolePermission value is the same as the corresponding default value in V3 + role_permissions_hash = r.role_permissions.pluck(:name, :value).to_h + role_permissions = { - CreateRoom: role_permissions_hash['can_create_rooms'] == "true" ? nil : "false", - CanRecord: role_permissions_hash['can_launch_recording'] == "true" ? nil : "false", - ManageUsers: role_permissions_hash['can_manage_users'] == "false" ? nil : "true", - ManageRoles: role_permissions_hash['can_edit_roles'] == "false" ? nil : "true", + CreateRoom: role_permissions_hash['can_create_rooms'] == "true" ? "true" : "false", + CanRecord: role_permissions_hash['can_launch_recording'] == "true" ? "true" : "false", + ManageUsers: role_permissions_hash['can_manage_users'] == "true" ? "true" : "false", + ManageRoles: role_permissions_hash['can_edit_roles'] == "true" ? "true" : "false", # In V3, can_manage_room_recordings is split into two distinct permissions: ManageRooms and ManageRecordings - ManageRooms: role_permissions_hash['can_manage_rooms_recordings'] == "false" ? nil : "true", - ManageRecordings: role_permissions_hash['can_manage_room_recordings'] == "false" ? nil : "true", - ManageSiteSettings: role_permissions_hash['can_edit_site_settings'] == "false" ? nil : "true" - }.compact + ManageRooms: role_permissions_hash['can_manage_rooms_recordings'] == "true" ? "true" : "false", + ManageRecordings: role_permissions_hash['can_manage_rooms_recordings'] == "true" ? "true" : "false", + ManageSiteSettings: role_permissions_hash['can_edit_site_settings'] == "true" ? "true" : "false" + } params = { role: { name: r.name.capitalize, role_permissions: role_permissions } } @@ -115,15 +117,15 @@ namespace :migrations do {} else { - record: parsed_room_settings["recording"] == false ? nil : "true", - muteOnStart: parsed_room_settings["muteOnStart"] == false ? nil : "true", - glAnyoneCanStart: parsed_room_settings["anyoneCanStart"] == false ? nil : "true", - glAnyoneJoinAsModerator: parsed_room_settings["joinModerator"] == false ? nil : "true", - guestPolicy: parsed_room_settings["requireModeratorApproval"] == false ? nil : "ASK_MODERATOR", - }.compact + record: parsed_room_settings["recording"] == true ? "true" : "false", + muteOnStart: parsed_room_settings["muteOnStart"] == true ? "true" : "false", + glAnyoneCanStart: parsed_room_settings["anyoneCanStart"] == true ? "true" : "false", + glAnyoneJoinAsModerator: parsed_room_settings["joinModerator"] == true ? "true" : "false", + guestPolicy: parsed_room_settings["requireModeratorApproval"] == true ? "ASK_MODERATOR" : "ALWAYS_ACCEPT" + } end - shared_users_emails = SharedAccess.joins(:user).where(room_id: r.id).pluck(:'users.email') + shared_users_emails = r.shared_access.joins(:user).pluck(:'users.email') params = { room: { friendly_id: r.uid, name: r.name, From 7496308f158603f53d181a6a51d3dc3cc48d76d5 Mon Sep 17 00:00:00 2001 From: Ahmad Farhat Date: Wed, 1 Feb 2023 14:46:50 -0500 Subject: [PATCH 21/37] Revert guest=true (#4723) --- app/controllers/concerns/bbb_server.rb | 1 - app/controllers/concerns/joiner.rb | 1 - spec/controllers/rooms_controller_spec.rb | 9 ++++----- 3 files changed, 4 insertions(+), 7 deletions(-) diff --git a/app/controllers/concerns/bbb_server.rb b/app/controllers/concerns/bbb_server.rb index 8f84544881..26d9ea2d46 100644 --- a/app/controllers/concerns/bbb_server.rb +++ b/app/controllers/concerns/bbb_server.rb @@ -56,7 +56,6 @@ def join_path(room, name, options = {}, uid = nil) join_opts[:join_via_html5] = true join_opts[:avatarURL] = options[:avatarURL] if options[:avatarURL].present? join_opts[:createTime] = room.last_session.to_datetime.strftime("%Q") if room.last_session - join_opts[:guest] = true if options[:guest] bbb_server.join_meeting_url(room.bbb_id, name, password, join_opts) end diff --git a/app/controllers/concerns/joiner.rb b/app/controllers/concerns/joiner.rb index 9d51ae1d84..f887ed43ec 100644 --- a/app/controllers/concerns/joiner.rb +++ b/app/controllers/concerns/joiner.rb @@ -68,7 +68,6 @@ def join_room(opts) opts[:record] = record_meeting opts[:require_moderator_approval] = room_setting_with_config("requireModeratorApproval") opts[:mute_on_start] = room_setting_with_config("muteOnStart") - opts[:guest] = current_user.nil? if current_user redirect_to join_path(@room, current_user.name, opts, current_user.uid) diff --git a/spec/controllers/rooms_controller_spec.rb b/spec/controllers/rooms_controller_spec.rb index ecea8272d8..d78f5d9dd4 100644 --- a/spec/controllers/rooms_controller_spec.rb +++ b/spec/controllers/rooms_controller_spec.rb @@ -270,7 +270,7 @@ def random_valid_room_params allow_any_instance_of(BigBlueButton::BigBlueButtonApi).to receive(:is_meeting_running?).and_return(true) post :join, params: { room_uid: @room, join_name: "Join Name" } - expect(response).to redirect_to(join_path(@owner.main_room, "Join Name", { guest: true }, response.cookies["guest_id"])) + expect(response).to redirect_to(join_path(@owner.main_room, "Join Name", {}, response.cookies["guest_id"])) end it "should use join name if user is not logged in and meeting running and moderator access code is enabled and set" do @@ -286,7 +286,7 @@ def random_valid_room_params post :join, params: { room_uid: room, join_name: "Join Name" }, session: { moderator_access_code: "abcdef" } - expect(response).to redirect_to(join_path(room, "Join Name", { user_is_moderator: true, guest: true }, + expect(response).to redirect_to(join_path(room, "Join Name", { user_is_moderator: true }, response.cookies["guest_id"])) end @@ -428,7 +428,7 @@ def random_valid_room_params post :join, params: { room_uid: room, join_name: "Join Name" }, session: { moderator_access_code: "abcdef" } - expect(response).to redirect_to(join_path(room, "Join Name", { user_is_moderator: true, guest: true }, + expect(response).to redirect_to(join_path(room, "Join Name", { user_is_moderator: true }, response.cookies["guest_id"])) end @@ -445,8 +445,7 @@ def random_valid_room_params post :join, params: { room_uid: room, join_name: "Join Name" }, session: { moderator_access_code: "abcdef" } - expect(response).to redirect_to(join_path(room, "Join Name", { user_is_moderator: true, guest: true }, -response.cookies["guest_id"])) + expect(response).to redirect_to(join_path(room, "Join Name", { user_is_moderator: true }, response.cookies["guest_id"])) end it "should redirect to login if a wrong moderator access code is supplied" do From 950a3f6c10b56bee0014a4ecb53b77f62671d441 Mon Sep 17 00:00:00 2001 From: Ahmad Farhat Date: Wed, 1 Feb 2023 15:02:29 -0500 Subject: [PATCH 22/37] Security fixes (#4725) --- Dockerfile | 2 +- Gemfile | 2 +- Gemfile.lock | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Dockerfile b/Dockerfile index fd8d4ef67f..32ba910555 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,4 @@ -FROM ruby:2.7.5-alpine3.14 AS base +FROM ruby:2.7.7-alpine3.16 AS base # Set a variable for the install location. ARG RAILS_ROOT=/usr/src/app diff --git a/Gemfile b/Gemfile index 1991b3dfd2..879ca47c19 100644 --- a/Gemfile +++ b/Gemfile @@ -59,7 +59,7 @@ end group :development, :test do gem 'byebug', '~> 11.1', platform: :mri - gem 'dotenv-rails', '~> 2.7', '>= 2.7.6' + gem 'dotenv-rails', '~> 2.8', '>= 2.8.1' end group :test do diff --git a/Gemfile.lock b/Gemfile.lock index 0b428ff3de..9e1518c027 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -507,7 +507,7 @@ DEPENDENCIES byebug (~> 11.1) cancancan (~> 2.3.0) coveralls (~> 0.8.23) - dotenv-rails (~> 2.7, >= 2.7.6) + dotenv-rails (~> 2.8, >= 2.8.1) factory_bot_rails (~> 6.2, >= 6.2.0) faker (~> 2.16) font-awesome-sass (~> 5.9.0) From 5be4e7b8c63ae7622393e4f9d3f73640cd7dc630 Mon Sep 17 00:00:00 2001 From: Khemissi Amir Date: Thu, 2 Feb 2023 19:23:32 +0100 Subject: [PATCH 23/37] V3 Migrations: Fixed `migrations:site_settings` task. (#4742) --- lib/tasks/migrations/migrations.rake | 27 +++++++++++++++++++++------ 1 file changed, 21 insertions(+), 6 deletions(-) diff --git a/lib/tasks/migrations/migrations.rake b/lib/tasks/migrations/migrations.rake index 117d5fdd20..f69d698cd4 100644 --- a/lib/tasks/migrations/migrations.rake +++ b/lib/tasks/migrations/migrations.rake @@ -180,12 +180,12 @@ namespace :migrations do # RoomConfigurations room_configurations = { - record: settings_hash['Room Configuration Recording'], - muteOnStart: settings_hash['Room Configuration Mute On Join'], - guestPolicy: settings_hash['Room Configuration Require Moderator'], - glAnyoneCanStart: settings_hash['Room Configuration Allow Any Start'], - glAnyoneJoinAsModerator: settings_hash['Room Configuration All Join Moderator'], - glRequireAuthentication: settings_hash['Room Authentication'] + record: infer_room_config_value(settings_hash['Room Configuration Recording']), + muteOnStart: infer_room_config_value(settings_hash['Room Configuration Mute On Join']), + guestPolicy: infer_room_config_value(settings_hash['Room Configuration Require Moderator']), + glAnyoneCanStart: infer_room_config_value(settings_hash['Room Configuration Allow Any Start']), + glAnyoneJoinAsModerator: infer_room_config_value(settings_hash['Room Configuration All Join Moderator']), + glRequireAuthentication: infer_room_config_value(settings_hash['Room Authentication']) }.compact params = { settings: { site_settings: site_settings, room_configurations: room_configurations } } @@ -265,4 +265,19 @@ namespace :migrations do "open" end end + + def infer_room_config_value(config_val) + return nil unless config_val.present? + + case config_val + when "enabled" + "true" + when "true" + "true" + when "disabled" + "false" + else + "optional" + end + end end From afc7e791239e3dc5a58fa66c025edf3ee81746cc Mon Sep 17 00:00:00 2001 From: Khemissi Amir Date: Fri, 3 Feb 2023 19:35:21 +0100 Subject: [PATCH 24/37] V3 Migrations: Minor Fixes to `migrations:site_settings` task. (#4746) --- lib/tasks/migrations/migrations.rake | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/lib/tasks/migrations/migrations.rake b/lib/tasks/migrations/migrations.rake index f69d698cd4..bab4efd484 100644 --- a/lib/tasks/migrations/migrations.rake +++ b/lib/tasks/migrations/migrations.rake @@ -165,27 +165,27 @@ namespace :migrations do task settings: :environment do |_task| has_encountred_issue = 0 - settings_hash = Setting.find_by(provider: 'greenlight').features.pluck(:name, :value).to_h + setting = Setting.includes(:features).find_by(provider: 'greenlight') # SiteSettings site_settings = { - PrimaryColor: settings_hash['Primary Color'], - PrimaryColorLight: settings_hash['Primary Color Lighten'], - Terms: settings_hash['Legal URL'], - PrivacyPolicy: settings_hash['Privacy Policy URL'], - RegistrationMethod: infer_registration_method(settings_hash['Registration Method']), - ShareRooms: settings_hash['Shared Access'], - PreuploadPresentation: settings_hash['Preupload Presentation'], + PrimaryColor: setting.get_value('Primary Color'), + PrimaryColorLight: setting.get_value('Primary Color Lighten'), + Terms: setting.get_value('Legal URL'), + PrivacyPolicy: setting.get_value('Privacy Policy URL'), + RegistrationMethod: infer_registration_method(setting.get_value('Registration Method')), + ShareRooms: setting.get_value('Shared Access'), + PreuploadPresentation: setting.get_value('Preupload Presentation'), }.compact # RoomConfigurations room_configurations = { - record: infer_room_config_value(settings_hash['Room Configuration Recording']), - muteOnStart: infer_room_config_value(settings_hash['Room Configuration Mute On Join']), - guestPolicy: infer_room_config_value(settings_hash['Room Configuration Require Moderator']), - glAnyoneCanStart: infer_room_config_value(settings_hash['Room Configuration Allow Any Start']), - glAnyoneJoinAsModerator: infer_room_config_value(settings_hash['Room Configuration All Join Moderator']), - glRequireAuthentication: infer_room_config_value(settings_hash['Room Authentication']) + record: infer_room_config_value(setting.get_value('Room Configuration Recording')), + muteOnStart: infer_room_config_value(setting.get_value('Room Configuration Mute On Join')), + guestPolicy: infer_room_config_value(setting.get_value('Room Configuration Require Moderator')), + glAnyoneCanStart: infer_room_config_value(setting.get_value('Room Configuration Allow Any Start')), + glAnyoneJoinAsModerator: infer_room_config_value(setting.get_value('Room Configuration All Join Moderator')), + glRequireAuthentication: infer_room_config_value(setting.get_value('Room Authentication')) }.compact params = { settings: { site_settings: site_settings, room_configurations: room_configurations } } From b99c76543d4d326986594f0a60507a8f8562837b Mon Sep 17 00:00:00 2001 From: Khemissi Amir Date: Mon, 13 Feb 2023 19:07:02 +0100 Subject: [PATCH 25/37] V3 migrations: Add missing header. (#4793) --- lib/tasks/migrations/migrations.rake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/tasks/migrations/migrations.rake b/lib/tasks/migrations/migrations.rake index bab4efd484..3332a283e4 100644 --- a/lib/tasks/migrations/migrations.rake +++ b/lib/tasks/migrations/migrations.rake @@ -4,7 +4,7 @@ namespace :migrations do DEFAULT_ROLES_MAP = { "admin" => "Administrator", "user" => "User" }.freeze COMMON = { - headers: { "Content-Type" => "application/json" }, + headers: { "Content-Type" => "application/json", "Accept" => "application/json" }, batch_size: 500, filtered_roles: %w[super_admin admin pending denied user], filtered_user_roles: %w[super_admin pending denied] From 3456ff2bb9d4ce21d38c6e24932714c8316df29a Mon Sep 17 00:00:00 2001 From: Jesus Federico Date: Tue, 21 Feb 2023 22:29:20 +0100 Subject: [PATCH 26/37] GIT-XX: making health check conditiopns configurable (#4823) --- app/controllers/health_check_controller.rb | 6 +++--- config/application.rb | 4 ++++ sample.env | 10 ++++++++++ 3 files changed, 17 insertions(+), 3 deletions(-) diff --git a/app/controllers/health_check_controller.rb b/app/controllers/health_check_controller.rb index 8ecc0414d2..599eae8f4c 100644 --- a/app/controllers/health_check_controller.rb +++ b/app/controllers/health_check_controller.rb @@ -26,9 +26,9 @@ def all @cache_expire = 10.seconds begin - cache_check - database_check - email_check + cache_check if Rails.configuration.health_check_cache_enabled + database_check if Rails.configuration.health_check_db_enabled + email_check if Rails.configuration.health_check_email_enabled rescue => e response = "Health Check Failure: #{e}" end diff --git a/config/application.rb b/config/application.rb index d23746fd7a..e91ef48ab0 100644 --- a/config/application.rb +++ b/config/application.rb @@ -188,5 +188,9 @@ def parse_bool(val, default = false) config.max_avatar_size = ENV['MAX_AVATAR_SIZE'].to_i.zero? ? 100_000 : ENV['MAX_AVATAR_SIZE'].to_i config.social_switching = ENV['SOCIAL_SWITCHING'] == "true" + + config.health_check_cache_enabled = ENV.fetch('ENABLE_HEALTH_CHECK_CACHE', 'true').casecmp?('true') + config.health_check_db_enabled = ENV.fetch('ENABLE_HEALTH_CHECK_DB', 'true').casecmp?('true') + config.health_check_email_enabled = ENV.fetch('ENABLE_HEALTH_CHECK_EMAIL', 'true').casecmp?('true') end end diff --git a/sample.env b/sample.env index 601f59163e..d62c0a1955 100644 --- a/sample.env +++ b/sample.env @@ -371,3 +371,13 @@ MAX_AVATAR_SIZE=100000 # Due CCVE-2015-9284, this setting needs to be enabled for omniauth to respond GET requests. # ENABLE_OMNIAUTH_GET=true| ENABLE_OMNIAUTH_GET=false + +# By default health_check proves the availability of CACHE, DB and EMAIL server +# but when the time of response requires is highly sensitive, in some cases it is necessary to disable +# them and relay only on the http response. In such case these env variables can be set. +# ENABLE_HEALTH_CHECK_CACHE=|false +# ENABLE_HEALTH_CHECK_DB=|false +# ENABLE_HEALTH_CHECK_EMAIL=|false +ENABLE_HEALTH_CHECK_CACHE=true +ENABLE_HEALTH_CHECK_DB=true +ENABLE_HEALTH_CHECK_EMAIL=true From 121f7493ab59d349ba0d7579ef9ffad132765e02 Mon Sep 17 00:00:00 2001 From: Samuel Couillard <43917914+scouillard@users.noreply.github.com> Date: Wed, 14 Jun 2023 10:34:40 -0400 Subject: [PATCH 27/37] Add Provider to v2 migration tasks (#4908) * Add Provider to migration file * Add Provider to migration file * Add greenlight as default task argument * Remove admin and user from filtered roles for tenants * Add provider * Fix migration file * Add default_enabled to possible rooms configs * Change v2 disable from v3 disable to v3 optional * Change v2 disable back to v3 disable --- lib/tasks/migrations/migrations.rake | 77 ++++++++++++++++++++-------- 1 file changed, 56 insertions(+), 21 deletions(-) mode change 100644 => 100755 lib/tasks/migrations/migrations.rake diff --git a/lib/tasks/migrations/migrations.rake b/lib/tasks/migrations/migrations.rake old mode 100644 new mode 100755 index 3332a283e4..3b96795c0c --- a/lib/tasks/migrations/migrations.rake +++ b/lib/tasks/migrations/migrations.rake @@ -6,19 +6,22 @@ namespace :migrations do COMMON = { headers: { "Content-Type" => "application/json", "Accept" => "application/json" }, batch_size: 500, - filtered_roles: %w[super_admin admin pending denied user], + filtered_roles: %w[admin user super_admin pending denied], filtered_user_roles: %w[super_admin pending denied] }.freeze desc "Migrates v2 resources to v3" - task :roles, [] => :environment do |_task, _args| + task :roles, [:provider] => :environment do |_task, args| + args.with_defaults(provider: "greenlight") has_encountred_issue = 0 Role.unscoped - .select(:id, :name) + .where(provider: args[:provider]) + .select(:id, :name, :provider) .includes(:role_permissions) .where.not(name: COMMON[:filtered_roles]) .find_each(batch_size: COMMON[:batch_size]) do |r| + # RolePermissions role_permissions_hash = r.role_permissions.pluck(:name, :value).to_h @@ -34,19 +37,22 @@ namespace :migrations do } params = { role: { name: r.name.capitalize, + provider: r.provider, role_permissions: role_permissions } } response = Net::HTTP.post(uri('roles'), payload(params), COMMON[:headers]) case response when Net::HTTPCreated - puts green "Succesfully migrated Role:" + puts green "Successfully migrated Role:" puts cyan "ID: #{r.id}" puts cyan "Name: #{params[:role][:name]}" + puts cyan "Provider: #{params[:role][:provider]}" else puts red "Unable to migrate Role:" puts yellow "ID: #{r.id}" puts yellow "Name: #{params[:role][:name]}" + puts yellow "Provider: #{params[:role][:provider]}" puts red "Errors: #{JSON.parse(response.body.to_s)['errors']}" has_encountred_issue = 1 # At least one of the migrations failed. end @@ -58,29 +64,39 @@ namespace :migrations do exit has_encountred_issue end - task :users, [:start, :stop] => :environment do |_task, args| + task :users, [:provider, :start, :stop] => :environment do |_task, args| + args.with_defaults(provider: "greenlight") start, stop = range(args) has_encountred_issue = 0 User.unscoped + .where(provider: args[:provider]) .select(:id, :uid, :name, :email, :social_uid, :language, :role_id) .includes(:role) .where.not(roles: { name: COMMON[:filtered_user_roles] }, deleted: true) .find_each(start: start, finish: stop, batch_size: COMMON[:batch_size]) do |u| role_name = infer_role_name(u.role.name) - params = { user: { name: u.name, email: u.email, external_id: u.social_uid, language: u.language, role: role_name } } + params = { user: + { name: u.name, + email: u.email, + external_id: u.social_uid, + provider: u.provider, + language: u.language, + role: role_name } } response = Net::HTTP.post(uri('users'), payload(params), COMMON[:headers]) case response when Net::HTTPCreated - puts green "Succesfully migrated User:" + puts green "Successfully migrated User:" puts cyan " UID: #{u.uid}" puts cyan " Name: #{params[:user][:name]}" + puts cyan " Provider: #{params[:user][:provider]}" else puts red "Unable to migrate User:" puts yellow "UID: #{u.uid}" puts yellow "Name: #{params[:user][:name]}" + puts yellow "Provider: #{params[:user][:provider]}" puts red "Errors: #{JSON.parse(response.body.to_s)['errors']}" has_encountred_issue = 1 # At least one of the migrations failed. end @@ -97,17 +113,21 @@ namespace :migrations do exit has_encountred_issue end - task :rooms, [:start, :stop] => :environment do |_task, args| + task :rooms, [:provider, :start, :stop] => :environment do |_task, args| + args.with_defaults(provider: "greenlight") start, stop = range(args) has_encountred_issue = 0 filtered_roles_ids = Role.unscoped + .where(provider: args[:provider]) .select(:id, :name) .where(name: COMMON[:filtered_user_roles]) .pluck(:id) - Room.unscoped.select(:id, :uid, :name, :bbb_id, :last_session, :user_id, :room_settings) + Room.unscoped + .select(:id, :uid, :name, :bbb_id, :last_session, :user_id, :room_settings) .includes(:owner) + .where('users.provider': args[:provider]) .where.not(users: { role_id: filtered_roles_ids, deleted: true }, deleted: true) .find_each(start: start, finish: stop, batch_size: COMMON[:batch_size]) do |r| # RoomSettings @@ -132,6 +152,7 @@ namespace :migrations do meeting_id: r.bbb_id, last_session: r.last_session&.to_datetime, owner_email: r.owner.email, + provider: r.owner.provider, room_settings: room_settings, shared_users_emails: shared_users_emails } } @@ -139,13 +160,15 @@ namespace :migrations do case response when Net::HTTPCreated - puts green "Succesfully migrated Room:" + puts green "Successfully migrated Room:" puts cyan "UID: #{r.uid}" - puts cyan "Name: #{r.name}" + puts cyan "Name: #{params[:room][:name]}" + puts cyan "Provider: #{params[:room][:provider]}" else puts red "Unable to migrate Room:" puts yellow "UID: #{r.uid}" - puts yellow "Name: #{r.name}" + puts yellow "Name: #{params[:room][:name]}" + puts yellow "Provider: #{params[:room][:provider]}}" puts red "Errors: #{JSON.parse(response.body.to_s)['errors']}" has_encountred_issue = 1 # At least one of the migrations failed. end @@ -162,10 +185,11 @@ namespace :migrations do exit has_encountred_issue end - task settings: :environment do |_task| + task :settings, [:provider] => :environment do |_task, args| + args.with_defaults(provider: "greenlight") has_encountred_issue = 0 - setting = Setting.includes(:features).find_by(provider: 'greenlight') + setting = Setting.includes(:features).find_by(provider: args[:provider]) # SiteSettings site_settings = { @@ -179,7 +203,7 @@ namespace :migrations do }.compact # RoomConfigurations - room_configurations = { + rooms_configurations = { record: infer_room_config_value(setting.get_value('Room Configuration Recording')), muteOnStart: infer_room_config_value(setting.get_value('Room Configuration Mute On Join')), guestPolicy: infer_room_config_value(setting.get_value('Room Configuration Require Moderator')), @@ -188,15 +212,24 @@ namespace :migrations do glRequireAuthentication: infer_room_config_value(setting.get_value('Room Authentication')) }.compact - params = { settings: { site_settings: site_settings, room_configurations: room_configurations } } + params = { settings: { provider: args[:provider], site_settings: site_settings, rooms_configurations: rooms_configurations } } response = Net::HTTP.post(uri('settings'), payload(params), COMMON[:headers]) case response when Net::HTTPCreated - puts green "Successfully migrated Settings" + puts green "Successfully migrated Site Settings" + puts cyan "Provider: #{args[:provider]}" + site_settings.each do |setting| + puts cyan "#{setting[0]}: #{setting[1]}" + end + puts green "Successfully migrated Rooms Configurations" + rooms_configurations.each do |rooms_config| + puts cyan "#{rooms_config[0]}: #{rooms_config[1]}" + end else puts red "Unable to migrate Settings" + puts red "Provider: #{args[:provider]}" puts red "Errors: #{JSON.parse(response.body.to_s)['errors']}" has_encountred_issue = 1 # At least one of the migrations failed. end @@ -217,7 +250,7 @@ namespace :migrations do end unless ENV["V3_SECRET_KEY_BASE"].size >= 32 - raise red 'Unable to migrate: Provided "V3_SECRET_KEY_BASE" must be at least 32 charchters in length.' + raise red 'Unable to migrate: Provided "V3_SECRET_KEY_BASE" must be at least 32 characters in length.' end key = ENV["V3_SECRET_KEY_BASE"][0..31] @@ -272,12 +305,14 @@ namespace :migrations do case config_val when "enabled" "true" - when "true" - "true" when "disabled" "false" + when "optional" + "default_enabled" + when "true" + "true" else "optional" - end + end end end From 75476aefe37a727632c7ad1604ab27fd1dc4d483 Mon Sep 17 00:00:00 2001 From: jfederico Date: Wed, 14 Jun 2023 13:00:16 -0400 Subject: [PATCH 28/37] [ci] removed latest tag from ci.build.release action --- .github/workflows/ci.build.release.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/ci.build.release.yml b/.github/workflows/ci.build.release.yml index f1a475a75f..7705a0c1a0 100644 --- a/.github/workflows/ci.build.release.yml +++ b/.github/workflows/ci.build.release.yml @@ -72,7 +72,6 @@ jobs: "${{ steps.ci_docker_repository.outputs.repository }}:v${{ steps.ci_tag_release_version.outputs.tag }}" "${{ steps.ci_docker_repository.outputs.repository }}:v${{ steps.ci_tag_release_major.outputs.tag }}" "${{ steps.ci_docker_repository.outputs.repository }}:v${{ steps.ci_tag_release_minor.outputs.tag }}" - "${{ steps.ci_docker_repository.outputs.repository }}:latest" build-args: "version_code=release-${{ steps.ci_tag_release_version.outputs.tag }}" cache-from: type=local,src=/tmp/.buildx-cache cache-to: type=local,dest=/tmp/.buildx-cache-new From 0df76ce47e92c1584ad5efb09c2fee2eab459562 Mon Sep 17 00:00:00 2001 From: Samuel Couillard <43917914+scouillard@users.noreply.github.com> Date: Mon, 19 Jun 2023 15:54:51 -0400 Subject: [PATCH 29/37] Set optional room configs to default_disabled instead of default_enabled except for Record (#5250) --- lib/tasks/migrations/migrations.rake | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/lib/tasks/migrations/migrations.rake b/lib/tasks/migrations/migrations.rake index 3b96795c0c..2ca4fe2fe5 100755 --- a/lib/tasks/migrations/migrations.rake +++ b/lib/tasks/migrations/migrations.rake @@ -202,9 +202,13 @@ namespace :migrations do PreuploadPresentation: setting.get_value('Preupload Presentation'), }.compact + + # Sets Record to default_enabled in V3 if set to optional in V2 + rooms_config_record_value = infer_room_config_value(setting.get_value('Room Configuration Recording')) + # RoomConfigurations rooms_configurations = { - record: infer_room_config_value(setting.get_value('Room Configuration Recording')), + record: rooms_config_record_value == "optional" ? "default_enabled" : rooms_config_record_value, muteOnStart: infer_room_config_value(setting.get_value('Room Configuration Mute On Join')), guestPolicy: infer_room_config_value(setting.get_value('Room Configuration Require Moderator')), glAnyoneCanStart: infer_room_config_value(setting.get_value('Room Configuration Allow Any Start')), @@ -307,8 +311,6 @@ namespace :migrations do "true" when "disabled" "false" - when "optional" - "default_enabled" when "true" "true" else From 5a3b0b2cfa801fc5dcf957efea6ee87bedb39588 Mon Sep 17 00:00:00 2001 From: Samuel Couillard <43917914+scouillard@users.noreply.github.com> Date: Tue, 20 Jun 2023 14:01:26 -0400 Subject: [PATCH 30/37] Add created_at field to User migration (#5264) --- lib/tasks/migrations/migrations.rake | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/lib/tasks/migrations/migrations.rake b/lib/tasks/migrations/migrations.rake index 2ca4fe2fe5..140980268f 100755 --- a/lib/tasks/migrations/migrations.rake +++ b/lib/tasks/migrations/migrations.rake @@ -71,7 +71,7 @@ namespace :migrations do User.unscoped .where(provider: args[:provider]) - .select(:id, :uid, :name, :email, :social_uid, :language, :role_id) + .select(:id, :uid, :name, :email, :social_uid, :language, :role_id, :created_at) .includes(:role) .where.not(roles: { name: COMMON[:filtered_user_roles] }, deleted: true) .find_each(start: start, finish: stop, batch_size: COMMON[:batch_size]) do |u| @@ -82,7 +82,8 @@ namespace :migrations do external_id: u.social_uid, provider: u.provider, language: u.language, - role: role_name } } + role: role_name, + created_at: u.created_at } } response = Net::HTTP.post(uri('users'), payload(params), COMMON[:headers]) From c2f88ad771254a5b823bdbb39ae805586d12d47d Mon Sep 17 00:00:00 2001 From: Samuel Couillard <43917914+scouillard@users.noreply.github.com> Date: Tue, 20 Jun 2023 14:28:42 -0400 Subject: [PATCH 31/37] Fix relative root in Migrations task (#5266) * Fix relative root in Migrations task * Remove slash at start of path --- lib/tasks/migrations/migrations.rake | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/tasks/migrations/migrations.rake b/lib/tasks/migrations/migrations.rake index 140980268f..bdb8217f1f 100755 --- a/lib/tasks/migrations/migrations.rake +++ b/lib/tasks/migrations/migrations.rake @@ -266,8 +266,8 @@ namespace :migrations do def uri(path) raise red 'Unable to migrate: No "V3_ENDPOINT" provided, please check your .env file.' unless ENV["V3_ENDPOINT"].present? - res = URI(ENV["V3_ENDPOINT"]) - res.path = "/api/v1/migrations/#{path}.json" + base_uri = URI(ENV["V3_ENDPOINT"]) + res = URI::join(base_uri, "api/v1/migrations/#{path}.json") res end From 735c2d84eb8d5e2596eab2b7bca592139bad1e8e Mon Sep 17 00:00:00 2001 From: Ahmad Farhat Date: Mon, 26 Jun 2023 11:38:45 -0400 Subject: [PATCH 32/37] Fixed migrations not migrating external accounts (#5291) --- lib/tasks/migrations/migrations.rake | 51 ++++++++++++++-------------- 1 file changed, 25 insertions(+), 26 deletions(-) diff --git a/lib/tasks/migrations/migrations.rake b/lib/tasks/migrations/migrations.rake index bdb8217f1f..2b18257d0d 100755 --- a/lib/tasks/migrations/migrations.rake +++ b/lib/tasks/migrations/migrations.rake @@ -12,16 +12,15 @@ namespace :migrations do desc "Migrates v2 resources to v3" task :roles, [:provider] => :environment do |_task, args| - args.with_defaults(provider: "greenlight") has_encountred_issue = 0 - Role.unscoped - .where(provider: args[:provider]) - .select(:id, :name, :provider) - .includes(:role_permissions) - .where.not(name: COMMON[:filtered_roles]) - .find_each(batch_size: COMMON[:batch_size]) do |r| + roles = Role.unscoped + roles = roles.where(provider: args[:provider]) if args[:provider].present? + roles = roles.select(:id, :name, :provider) + .includes(:role_permissions) + .where.not(name: COMMON[:filtered_roles]) + roles.find_each(batch_size: COMMON[:batch_size]) do |r| # RolePermissions role_permissions_hash = r.role_permissions.pluck(:name, :value).to_h @@ -65,16 +64,16 @@ namespace :migrations do end task :users, [:provider, :start, :stop] => :environment do |_task, args| - args.with_defaults(provider: "greenlight") start, stop = range(args) has_encountred_issue = 0 - User.unscoped - .where(provider: args[:provider]) - .select(:id, :uid, :name, :email, :social_uid, :language, :role_id, :created_at) - .includes(:role) - .where.not(roles: { name: COMMON[:filtered_user_roles] }, deleted: true) - .find_each(start: start, finish: stop, batch_size: COMMON[:batch_size]) do |u| + user = User.unscoped + user = user.where(provider: args[:provider]) if args[:provider].present? + user = user.select(:id, :uid, :name, :email, :social_uid, :language, :role_id, :created_at) + .includes(:role) + .where.not(roles: { name: COMMON[:filtered_user_roles] }, deleted: true) + + user.find_each(start: start, finish: stop, batch_size: COMMON[:batch_size]) do |u| role_name = infer_role_name(u.role.name) params = { user: { name: u.name, @@ -115,22 +114,22 @@ namespace :migrations do end task :rooms, [:provider, :start, :stop] => :environment do |_task, args| - args.with_defaults(provider: "greenlight") start, stop = range(args) has_encountred_issue = 0 filtered_roles_ids = Role.unscoped - .where(provider: args[:provider]) - .select(:id, :name) - .where(name: COMMON[:filtered_user_roles]) - .pluck(:id) - - Room.unscoped - .select(:id, :uid, :name, :bbb_id, :last_session, :user_id, :room_settings) - .includes(:owner) - .where('users.provider': args[:provider]) - .where.not(users: { role_id: filtered_roles_ids, deleted: true }, deleted: true) - .find_each(start: start, finish: stop, batch_size: COMMON[:batch_size]) do |r| + filtered_roles_ids = filtered_roles_ids.where(provider: args[:provider]) if args[:provider].present? + filtered_roles_ids = filtered_roles_ids.select(:id, :name) + .where(name: COMMON[:filtered_user_roles]) + .pluck(:id) + + rooms = Room.unscoped + .select(:id, :uid, :name, :bbb_id, :last_session, :user_id, :room_settings) + .includes(:owner) + rooms = rooms.where('users.provider': args[:provider]) if args[:provider].present? + rooms = rooms.where.not(users: { role_id: filtered_roles_ids, deleted: true }, deleted: true) + + rooms.find_each(start: start, finish: stop, batch_size: COMMON[:batch_size]) do |r| # RoomSettings parsed_room_settings = JSON.parse(r.room_settings) # Returns nil if the RoomSetting value is the same as the corresponding default value in V3 From 11533ede144ea97de52bbf4494b0e8a7e1eb09cc Mon Sep 17 00:00:00 2001 From: Moritz <15136847+Nemental@users.noreply.github.com> Date: Tue, 3 Oct 2023 20:16:28 +0200 Subject: [PATCH 33/37] style(migrations): removed double brackets (#5309) --- lib/tasks/migrations/migrations.rake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/tasks/migrations/migrations.rake b/lib/tasks/migrations/migrations.rake index 2b18257d0d..e9fd564309 100755 --- a/lib/tasks/migrations/migrations.rake +++ b/lib/tasks/migrations/migrations.rake @@ -168,7 +168,7 @@ namespace :migrations do puts red "Unable to migrate Room:" puts yellow "UID: #{r.uid}" puts yellow "Name: #{params[:room][:name]}" - puts yellow "Provider: #{params[:room][:provider]}}" + puts yellow "Provider: #{params[:room][:provider]}" puts red "Errors: #{JSON.parse(response.body.to_s)['errors']}" has_encountred_issue = 1 # At least one of the migrations failed. end From 8a15404b97ffa7a37cc24a41110fab5e347da0c3 Mon Sep 17 00:00:00 2001 From: Ahmad Farhat Date: Tue, 3 Oct 2023 15:52:35 -0400 Subject: [PATCH 34/37] Added access codes to migration script (#5433) --- lib/tasks/migrations/migrations.rake | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/lib/tasks/migrations/migrations.rake b/lib/tasks/migrations/migrations.rake index e9fd564309..6c4b8bca82 100755 --- a/lib/tasks/migrations/migrations.rake +++ b/lib/tasks/migrations/migrations.rake @@ -141,10 +141,13 @@ namespace :migrations do muteOnStart: parsed_room_settings["muteOnStart"] == true ? "true" : "false", glAnyoneCanStart: parsed_room_settings["anyoneCanStart"] == true ? "true" : "false", glAnyoneJoinAsModerator: parsed_room_settings["joinModerator"] == true ? "true" : "false", - guestPolicy: parsed_room_settings["requireModeratorApproval"] == true ? "ASK_MODERATOR" : "ALWAYS_ACCEPT" + guestPolicy: parsed_room_settings["requireModeratorApproval"] == true ? "ASK_MODERATOR" : "ALWAYS_ACCEPT", } end + room_settings[:glViewerAccessCode] = r.access_code if r.access_code.present? + room_settings[:glModeratorAccessCode] = r.moderator_access_code if r.moderator_access_code.present? + shared_users_emails = r.shared_access.joins(:user).pluck(:'users.email') params = { room: { friendly_id: r.uid, From 101aa0b6b156f5dfbe806388037d1474746d637f Mon Sep 17 00:00:00 2001 From: farhatahmad Date: Wed, 18 Oct 2023 14:51:44 -0400 Subject: [PATCH 35/37] Small fix for recording value --- lib/tasks/migrations/migrations.rake | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/lib/tasks/migrations/migrations.rake b/lib/tasks/migrations/migrations.rake index 6c4b8bca82..8450e664f0 100755 --- a/lib/tasks/migrations/migrations.rake +++ b/lib/tasks/migrations/migrations.rake @@ -207,7 +207,11 @@ namespace :migrations do # Sets Record to default_enabled in V3 if set to optional in V2 - rooms_config_record_value = infer_room_config_value(setting.get_value('Room Configuration Recording')) + rooms_config_record_value = if setting.get_value("Require Recording Consent") != "true" + "true" + else + infer_room_config_value(setting.get_value('Room Configuration Recording')) + end # RoomConfigurations rooms_configurations = { From 30882ef15c971df0e9ca4ec6ff0b0c0f29ac0628 Mon Sep 17 00:00:00 2001 From: Ahmad Farhat Date: Tue, 21 Nov 2023 13:41:24 -0500 Subject: [PATCH 36/37] Pass password_digest to v3 in user migration (#5556) --- lib/tasks/migrations/migrations.rake | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/tasks/migrations/migrations.rake b/lib/tasks/migrations/migrations.rake index 8450e664f0..2f1ce6a565 100755 --- a/lib/tasks/migrations/migrations.rake +++ b/lib/tasks/migrations/migrations.rake @@ -69,7 +69,7 @@ namespace :migrations do user = User.unscoped user = user.where(provider: args[:provider]) if args[:provider].present? - user = user.select(:id, :uid, :name, :email, :social_uid, :language, :role_id, :created_at) + user = user.select(:id, :uid, :name, :email,:password_digest, :social_uid, :language, :role_id, :created_at) .includes(:role) .where.not(roles: { name: COMMON[:filtered_user_roles] }, deleted: true) @@ -79,6 +79,7 @@ namespace :migrations do { name: u.name, email: u.email, external_id: u.social_uid, + password_digest: u.password_digest, provider: u.provider, language: u.language, role: role_name, From 04c72881564879afc1ec28a18e9f3437f006a3e2 Mon Sep 17 00:00:00 2001 From: Daniel Molkentin Date: Wed, 28 Feb 2024 16:50:32 +0100 Subject: [PATCH 37/37] feat: Implement room presentation migration (#5694) (#5696) --- lib/tasks/migrations/migrations.rake | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/lib/tasks/migrations/migrations.rake b/lib/tasks/migrations/migrations.rake index 2f1ce6a565..b000c8a88a 100755 --- a/lib/tasks/migrations/migrations.rake +++ b/lib/tasks/migrations/migrations.rake @@ -159,6 +159,10 @@ namespace :migrations do provider: r.owner.provider, room_settings: room_settings, shared_users_emails: shared_users_emails } } + if r.presentation.attached? + params[:room][:presentation] = { blob: Base64.encode64(r.presentation.blob.download), + filename: r.presentation.blob.filename.to_s } + end response = Net::HTTP.post(uri('rooms'), payload(params), COMMON[:headers])