Skip to content

Commit

Permalink
Fix: リモートからのアカウント削除時エラーが出る問題 (#872)
Browse files Browse the repository at this point in the history
* Fix: アカウント削除時エラーが出る問題

* nilに変更

* 削除するタイミングと条件を調整

* Fix test
  • Loading branch information
kmycode authored Oct 9, 2024
1 parent 74a6238 commit be56722
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
1 change: 1 addition & 0 deletions app/models/concerns/account/associations.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 5 additions & 0 deletions app/services/delete_account_service.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

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

0 comments on commit be56722

Please sign in to comment.