diff options
author | ThibG <thib@sitedethib.com> | 2020-12-21 18:22:17 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-12-21 18:22:17 +0100 |
commit | 43961035a906cd8bccdf4c1ac023980b37823bb3 (patch) | |
tree | 9327e444230f7ee3eef18b2109aac371b807ba31 /app | |
parent | 6f51fd743590c8fd8dd95e48dc24e4472d46480b (diff) |
Fix some notifications not being deleted on poll/status deletion (#15402)
* Fix deleting polls not deleting notifications * Fix fav notification deletion when deleting a toot * Refactor DeleteAccountService spec * Add DeleteAccountService tests for other associations and notifications * Add favourite handling spec in status removal Co-authored-by: Claire <claire.github-309c@sitedethib.com>
Diffstat (limited to 'app')
-rw-r--r-- | app/models/status.rb | 2 | ||||
-rw-r--r-- | app/services/delete_account_service.rb | 4 |
2 files changed, 4 insertions, 2 deletions
diff --git a/app/models/status.rb b/app/models/status.rb index f1b3b75ce..96d90e1c2 100644 --- a/app/models/status.rb +++ b/app/models/status.rb @@ -56,7 +56,7 @@ class Status < ApplicationRecord belongs_to :thread, foreign_key: 'in_reply_to_id', class_name: 'Status', inverse_of: :replies, optional: true belongs_to :reblog, foreign_key: 'reblog_of_id', class_name: 'Status', inverse_of: :reblogs, optional: true - has_many :favourites, inverse_of: :status, dependent: :delete_all + has_many :favourites, inverse_of: :status, dependent: :destroy has_many :bookmarks, inverse_of: :status, dependent: :destroy has_many :reblogs, foreign_key: 'reblog_of_id', class_name: 'Status', inverse_of: :reblog, dependent: :destroy has_many :replies, foreign_key: 'in_reply_to_id', class_name: 'Status', inverse_of: :thread diff --git a/app/services/delete_account_service.rb b/app/services/delete_account_service.rb index fe9b30b17..fa834e775 100644 --- a/app/services/delete_account_service.rb +++ b/app/services/delete_account_service.rb @@ -123,7 +123,9 @@ class DeleteAccountService < BaseService next if @options[:reserve_username] && reported_status_ids.include?(poll.status_id) # We can safely delete the poll rather than destroy it, as any non-reported - # status should have been deleted already + # status should have been deleted already, as long as we take care of + # notifications. + Notification.where(poll: poll).delete_all poll.delete end |