From 6b8ff1cf6e9b98af3ad4ab9a229425b634283525 Mon Sep 17 00:00:00 2001 From: Claire Date: Mon, 25 Nov 2024 11:27:58 +0100 Subject: [PATCH] Fix `TagFollow` records not being correctly handled in account operations (#33063) --- app/models/concerns/account/interactions.rb | 3 +++ app/models/concerns/account/merging.rb | 2 +- app/services/delete_account_service.rb | 1 + lib/mastodon/cli/maintenance.rb | 2 ++ 4 files changed, 7 insertions(+), 1 deletion(-) diff --git a/app/models/concerns/account/interactions.rb b/app/models/concerns/account/interactions.rb index 536afba17f..fc0a24f624 100644 --- a/app/models/concerns/account/interactions.rb +++ b/app/models/concerns/account/interactions.rb @@ -88,6 +88,9 @@ module Account::Interactions has_many :remote_severed_relationships, foreign_key: 'remote_account_id', inverse_of: :remote_account end + # Hashtag follows + has_many :tag_follows, inverse_of: :account, dependent: :destroy + # Account notes has_many :account_notes, dependent: :destroy diff --git a/app/models/concerns/account/merging.rb b/app/models/concerns/account/merging.rb index bd8b162238..181061c37e 100644 --- a/app/models/concerns/account/merging.rb +++ b/app/models/concerns/account/merging.rb @@ -16,7 +16,7 @@ module Account::Merging Follow, FollowRequest, Block, Mute, AccountModerationNote, AccountPin, AccountStat, ListAccount, PollVote, Mention, AccountDeletionRequest, AccountNote, FollowRecommendationSuppression, - Appeal + Appeal, TagFollow ] owned_classes.each do |klass| diff --git a/app/services/delete_account_service.rb b/app/services/delete_account_service.rb index 0c03267d43..7d06302af5 100644 --- a/app/services/delete_account_service.rb +++ b/app/services/delete_account_service.rb @@ -50,6 +50,7 @@ class DeleteAccountService < BaseService owned_lists scheduled_statuses status_pins + tag_follows ) ASSOCIATIONS_ON_DESTROY = %w( diff --git a/lib/mastodon/cli/maintenance.rb b/lib/mastodon/cli/maintenance.rb index 0b84047a1c..532fbc328a 100644 --- a/lib/mastodon/cli/maintenance.rb +++ b/lib/mastodon/cli/maintenance.rb @@ -43,6 +43,7 @@ module Mastodon::CLI class BulkImport < ApplicationRecord; end class SoftwareUpdate < ApplicationRecord; end class SeveredRelationship < ApplicationRecord; end + class TagFollow < ApplicationRecord; end class DomainBlock < ApplicationRecord enum :severity, { silence: 0, suspend: 1, noop: 2 } @@ -102,6 +103,7 @@ module Mastodon::CLI owned_classes << AccountIdentityProof if db_table_exists?(:account_identity_proofs) owned_classes << Appeal if db_table_exists?(:appeals) owned_classes << BulkImport if db_table_exists?(:bulk_imports) + owned_classes << TagFollow if db_table_exists?(:tag_follows) owned_classes.each do |klass| klass.where(account_id: other_account.id).find_each do |record|