diff --git a/bookwyrm/templates/ostatus/error.html b/bookwyrm/templates/ostatus/error.html index 91bb6a0a..8a047172 100644 --- a/bookwyrm/templates/ostatus/error.html +++ b/bookwyrm/templates/ostatus/error.html @@ -42,6 +42,10 @@
{% blocktrans %}You have blocked {{ account }}{% endblocktrans %}
{% blocktrans %}{{ account }} has blocked you{% endblocktrans %}
+{% blocktrans %}You are already following {{ account }}{% endblocktrans %}
diff --git a/bookwyrm/views/follow.py b/bookwyrm/views/follow.py index 1555fc5e..83b90035 100644 --- a/bookwyrm/views/follow.py +++ b/bookwyrm/views/follow.py @@ -109,17 +109,33 @@ def ostatus_follow_request(request): if user is None or user == "": error = "ostatus_subscribe" - if hasattr(request.user, "blocks") and user in request.user.blocks.all(): - error = "is_blocked" + # don't do these checks for AnonymousUser before they sign in + if request.user.id: - if hasattr(user, "followers") and request.user in user.followers.all(): - error = "already_following" - - if ( - hasattr(user, "follower_requests") - and request.user in user.follower_requests.all() - ): - error = "already_requested" + # you have blocked them so you probably don't want to follow + if ( + hasattr(request.user, "blocks") + and user in request.user.blocks.all() + ): + error = "is_blocked" + # they have blocked you + if ( + hasattr(user, "blocks") + and request.user in user.blocks.all() + ): + error = "has_blocked" + # you're already following them + if ( + hasattr(user, "followers") + and request.user in user.followers.all() + ): + error = "already_following" + # you're not following yet but you already asked + if ( + hasattr(user, "follower_requests") + and request.user in user.follower_requests.all() + ): + error = "already_requested" data = {"account": account, "user": user, "error": error}