From be567228efc2e15f5645c8c9a7ead9b3d33b78de Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?KMY=EF=BC=88=E9=9B=AA=E3=81=82=E3=81=99=E3=81=8B=EF=BC=89?= Date: Thu, 10 Oct 2024 07:47:21 +0900 Subject: [PATCH] =?UTF-8?q?Fix:=20=E3=83=AA=E3=83=A2=E3=83=BC=E3=83=88?= =?UTF-8?q?=E3=81=8B=E3=82=89=E3=81=AE=E3=82=A2=E3=82=AB=E3=82=A6=E3=83=B3?= =?UTF-8?q?=E3=83=88=E5=89=8A=E9=99=A4=E6=99=82=E3=82=A8=E3=83=A9=E3=83=BC?= =?UTF-8?q?=E3=81=8C=E5=87=BA=E3=82=8B=E5=95=8F=E9=A1=8C=20(#872)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Fix: アカウント削除時エラーが出る問題 * nilに変更 * 削除するタイミングと条件を調整 * Fix test --- app/models/concerns/account/associations.rb | 1 + app/services/delete_account_service.rb | 5 +++++ 2 files changed, 6 insertions(+) diff --git a/app/models/concerns/account/associations.rb b/app/models/concerns/account/associations.rb index 3040da01de3540..ec8766f709b4e2 100644 --- a/app/models/concerns/account/associations.rb +++ b/app/models/concerns/account/associations.rb @@ -19,6 +19,7 @@ module Account::Associations has_many :conversations, class_name: 'AccountConversation', dependent: :destroy, inverse_of: :account has_many :scheduled_statuses, inverse_of: :account, dependent: :destroy has_many :scheduled_expiration_statuses, inverse_of: :account, dependent: :destroy + has_many :ng_rule_histories, inverse_of: :account, dependent: :destroy # Notifications has_many :notifications, inverse_of: :account, dependent: :destroy diff --git a/app/services/delete_account_service.rb b/app/services/delete_account_service.rb index 0c90eeb82dd02f..925b2efea6ad5a 100644 --- a/app/services/delete_account_service.rb +++ b/app/services/delete_account_service.rb @@ -170,6 +170,7 @@ def purge_content! purge_feeds! purge_other_associations! + remove_ng_rule_history_relations! unless keep_account_record? @account.destroy unless keep_account_record? end @@ -273,6 +274,10 @@ def purge_profile! @account.save! end + def remove_ng_rule_history_relations! + @account.ng_rule_histories.update_all(account_id: nil) + end + def fulfill_deletion_request! @account.deletion_request&.destroy end