Skip to content

Commit

Permalink
fix relationship migration
Browse files Browse the repository at this point in the history
  • Loading branch information
Her Email authored and alphatownsman committed Nov 9, 2023
1 parent 2db137a commit 2015d7b
Showing 1 changed file with 5 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,18 @@


def migrate_relationships(apps, schema_editor):
User = apps.get_model("users", "User")
APIdentity = apps.get_model("users", "APIdentity")
from users.models import APIdentity, User

logger.info(f"Migrate user relationship")
for user in tqdm(User.objects.all()):
for user in tqdm(User.objects.filter(is_active=True)):
for target in user.local_following.all():
user.identity.follow(User.objects.get(pk=target).identity)
for target in user.local_blocking.all():
user.identity.block(User.objects.get(pk=target).identity)
for target in user.local_muting.all():
user.identity.block(User.objects.get(pk=target).identity)
user.sync_relationship()
for user in tqdm(User.objects.all()):
for user in tqdm(User.objects.filter(is_active=True)):
for target_identity in user.identity.follow_requesting_identities:
target_identity.accept_follow_request(user.identity)

Expand All @@ -29,7 +29,6 @@ class Migration(migrations.Migration):
]

operations = [
migrations.RunPython(migrate_relationships),
migrations.AddField(
model_name="preference",
name="mastodon_skip_relationship",
Expand All @@ -40,4 +39,5 @@ class Migration(migrations.Migration):
name="mastodon_skip_userinfo",
field=models.BooleanField(default=False),
),
migrations.RunPython(migrate_relationships),
]

0 comments on commit 2015d7b

Please sign in to comment.