0
0
Fork 0

Change Move handler to also move list memberships (#24808)

This commit is contained in:
Claire 2023-05-03 14:03:38 +02:00 committed by GitHub
parent 9a52a7f7a0
commit c98b012583
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 54 additions and 16 deletions

View file

@ -8,9 +8,9 @@ class MoveWorker
@target_account = Account.find(target_account_id)
if @target_account.local? && @source_account.local?
nb_moved = rewrite_follows!
@source_account.update_count!(:followers_count, -nb_moved)
@target_account.update_count!(:followers_count, nb_moved)
num_moved = rewrite_follows!
@source_account.update_count!(:followers_count, -num_moved)
@target_account.update_count!(:followers_count, num_moved)
else
queue_follow_unfollows!
end
@ -29,12 +29,18 @@ class MoveWorker
private
def rewrite_follows!
num_moved = 0
@source_account.passive_relationships
.where(account: Account.local)
.where.not(account: @target_account.followers.local)
.where.not(account_id: @target_account.id)
.in_batches
.update_all(target_account_id: @target_account.id)
.in_batches do |follows|
ListAccount.where(follow: follows).in_batches.update_all(account_id: @target_account.id)
num_moved += follows.update_all(target_account_id: @target_account.id)
end
num_moved
end
def queue_follow_unfollows!