From feaf0d5e52ec8d2887b2d14e3bcd3bfc49446cf4 Mon Sep 17 00:00:00 2001 From: Hugh Rundle Date: Mon, 29 Nov 2021 07:11:57 +1100 Subject: [PATCH] handle username errors in remote follow form --- bookwyrm/templates/ostatus/error.html | 5 +++++ bookwyrm/views/follow.py | 3 +++ 2 files changed, 8 insertions(+) diff --git a/bookwyrm/templates/ostatus/error.html b/bookwyrm/templates/ostatus/error.html index b6e858e2..cb1aec40 100644 --- a/bookwyrm/templates/ostatus/error.html +++ b/bookwyrm/templates/ostatus/error.html @@ -33,6 +33,11 @@

{% blocktrans %}Something went wrong trying to follow {{ account }}{% endblocktrans %}

{% trans 'Check you have the correct username before trying again.' %}

+ {% elif error == 'remote_subscribe' %} +
+

{% blocktrans %}Something went wrong trying to follow from {{ account }}{% endblocktrans %}

+

{% trans 'Check you have the correct username before trying again.' %}

+
{% elif error == 'is_blocked' %}

{% blocktrans %}You have blocked {{ account }}{% endblocktrans %}

diff --git a/bookwyrm/views/follow.py b/bookwyrm/views/follow.py index 58d97985..fcab5d6a 100644 --- a/bookwyrm/views/follow.py +++ b/bookwyrm/views/follow.py @@ -148,5 +148,8 @@ def remote_follow(request): """direct user to follow from remote account using ostatus subscribe protocol""" remote_user = request.POST.get("remote_user") template = subscribe_remote_webfinger(remote_user) + if template is None: + data = {"account": remote_user, "user": None, "error": "remote_subscribe"} + return TemplateResponse(request, "ostatus/subscribe.html", data) url = template.replace("{uri}", request.POST.get("user")) return redirect(url)