Merge pull request #2167 from bookwyrm-social/follow-button

Fixes logic error in checking relationships
This commit is contained in:
Mouse Reeve 2022-07-03 06:49:42 -07:00 committed by GitHub
commit 6e7c9b76c6
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 4 additions and 4 deletions

View file

@ -218,7 +218,7 @@ def clear_cache(user_subject, user_object):
"""clear relationship cache"""
cache.delete_many(
[
f"relationship-{user_subject.id}-{user_object.id}",
f"relationship-{user_object.id}-{user_subject.id}",
f"cached-relationship-{user_subject.id}-{user_object.id}",
f"cached-relationship-{user_object.id}-{user_subject.id}",
]
)

View file

@ -42,7 +42,7 @@ def get_relationship(context, user_object):
"""caches the relationship between the logged in user and another user"""
user = context["request"].user
return get_or_set(
f"relationship-{user.id}-{user_object.id}",
f"cached-relationship-{user.id}-{user_object.id}",
get_relationship_name,
user,
user_object,
@ -61,6 +61,6 @@ def get_relationship_name(user, user_object):
types["is_blocked"] = True
elif user_object in user.following.all():
types["is_following"] = True
elif user_object in user.follower_requests.all():
elif user in user_object.follower_requests.all():
types["is_follow_pending"] = True
return types