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 2dd26b1 commit 321c5e7
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,15 @@ def migrate_relationships(apps, schema_editor):
APIdentity = apps.get_model("users", "APIdentity")
logger.info(f"Migrate user relationship")
for user in tqdm(User.objects.all()):
for target in user.local_following:
for target in user.local_following.all():
user.identity.follow(User.objects.get(pk=target).identity)
for target in user.local_blocking:
for target in user.local_blocking.all():
user.identity.block(User.objects.get(pk=target).identity)
for target in user.local_muting:
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 req in user.identity.following_request:
target_identity = APIdentity.objects.get(pk=req)
for target_identity in user.identity.follow_requesting_identities:
target_identity.accept_follow_request(user.identity)


Expand Down
6 changes: 3 additions & 3 deletions users/models/apidentity.py
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ def requested_follower_identities(self):

@property
def follow_requesting_identities(self):
return APIdentity.objects.filter(pk__in=self.following_request)
return APIdentity.objects.filter(pk__in=self.following_requests)

@property
def rejecting(self):
Expand All @@ -165,7 +165,7 @@ def requested_followers(self):
return Takahe.get_requested_follower_ids(self.pk)

@property
def following_request(self):
def following_requests(self):
return Takahe.get_following_request_ids(self.pk)

def accept_follow_request(self, target: "APIdentity"):
Expand Down Expand Up @@ -204,7 +204,7 @@ def is_following(self, target: "APIdentity"):
return target.pk in self.following

def is_requesting(self, target: "APIdentity"):
return target.pk in self.following_request
return target.pk in self.following_requests

def is_requested(self, target: "APIdentity"):
return target.pk in self.requested_followers
Expand Down

0 comments on commit 321c5e7

Please sign in to comment.