Skip to content

Commit

Permalink
Fix TagFollow records not being correctly handled in account operat…
Browse files Browse the repository at this point in the history
…ions (mastodon#33063)
  • Loading branch information
ClearlyClaire authored Nov 25, 2024
1 parent 1a88c05 commit 2d8fed2
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 1 deletion.
3 changes: 3 additions & 0 deletions app/models/concerns/account/interactions.rb
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,9 @@ def follow_mapping(query, field)
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

Expand Down
2 changes: 1 addition & 1 deletion app/models/concerns/account/merging.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ def merge_with!(other_account)
Follow, FollowRequest, Block, Mute,
AccountModerationNote, AccountPin, AccountStat, ListAccount,
PollVote, Mention, AccountDeletionRequest, AccountNote, FollowRecommendationSuppression,
Appeal
Appeal, TagFollow
]

owned_classes.each do |klass|
Expand Down
1 change: 1 addition & 0 deletions app/services/delete_account_service.rb
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ class DeleteAccountService < BaseService
owned_lists
scheduled_statuses
status_pins
tag_follows
)

ASSOCIATIONS_ON_DESTROY = %w(
Expand Down
2 changes: 2 additions & 0 deletions lib/mastodon/cli/maintenance.rb
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ class Webhook < ApplicationRecord; end
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 }
Expand Down Expand Up @@ -102,6 +103,7 @@ def merge_with!(other_account)
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|
Expand Down

0 comments on commit 2d8fed2

Please sign in to comment.