From c9b16729f6060bedcda61d1f5b1cee5cb445adde Mon Sep 17 00:00:00 2001 From: Ahmad Farhat Date: Thu, 24 Dec 2020 13:54:27 -0500 Subject: [PATCH] Make room delete permanent (#2390) --- app/controllers/rooms_controller.rb | 5 ++++- app/controllers/users_controller.rb | 2 ++ spec/controllers/users_controller_spec.rb | 2 ++ 3 files changed, 8 insertions(+), 1 deletion(-) diff --git a/app/controllers/rooms_controller.rb b/app/controllers/rooms_controller.rb index 41b4144d..8c27ea17 100644 --- a/app/controllers/rooms_controller.rb +++ b/app/controllers/rooms_controller.rb @@ -137,7 +137,10 @@ class RoomsController < ApplicationController begin # Don't delete the users home room. raise I18n.t("room.delete.home_room") if @room == @room.owner.main_room - @room.destroy + + # Destroy all recordings then permanently delete the room + delete_all_recordings(@room.bbb_id) + @room.destroy(true) rescue => e flash[:alert] = I18n.t("room.delete.fail", error: e) else diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index 70db2471..ac603317 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -155,6 +155,8 @@ class UsersController < ApplicationController # Permanently delete the rooms under the user if they have not been reassigned if perm_delete @user.rooms.include_deleted.each do |room| + # Destroy all recordings then permanently delete the room + delete_all_recordings(room.bbb_id) room.destroy(true) end end diff --git a/spec/controllers/users_controller_spec.rb b/spec/controllers/users_controller_spec.rb index 59cfe95c..9b37d5a9 100644 --- a/spec/controllers/users_controller_spec.rb +++ b/spec/controllers/users_controller_spec.rb @@ -550,6 +550,7 @@ describe UsersController, type: :controller do it "allows admins to permanently delete users" do allow(Rails.configuration).to receive(:loadbalanced_configuration).and_return(true) allow_any_instance_of(User).to receive(:greenlight_account?).and_return(true) + allow_any_instance_of(BbbServer).to receive(:delete_all_recordings).and_return("") allow_any_instance_of(ApplicationController).to receive(:set_user_domain).and_return("provider1") controller.instance_variable_set(:@user_domain, "provider1") @@ -568,6 +569,7 @@ describe UsersController, type: :controller do it "permanently deletes the users rooms if the user is permanently deleted" do allow(Rails.configuration).to receive(:loadbalanced_configuration).and_return(true) allow_any_instance_of(User).to receive(:greenlight_account?).and_return(true) + allow_any_instance_of(BbbServer).to receive(:delete_all_recordings).and_return("") allow_any_instance_of(ApplicationController).to receive(:set_user_domain).and_return("provider1") controller.instance_variable_set(:@user_domain, "provider1")