From 48d92f19903836deb057be45c69b95b31b8103da Mon Sep 17 00:00:00 2001 From: Mouse Reeve Date: Fri, 14 Feb 2020 20:24:35 -0800 Subject: [PATCH] Handle follow request accept activities --- fedireads/incoming.py | 14 ++++++++++++-- fedireads/templates/user.html | 2 +- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/fedireads/incoming.py b/fedireads/incoming.py index 355ab2699..0513c2eab 100644 --- a/fedireads/incoming.py +++ b/fedireads/incoming.py @@ -100,8 +100,7 @@ def shared_inbox(request): return handle_incoming_create(activity) if activity['type'] == 'Accept': - # aww yay, friendship - return HttpResponse() + return handle_incoming_follow_accept(activity) return HttpResponseNotFound() @@ -267,6 +266,17 @@ def handle_incoming_follow(activity): }) +def handle_incoming_follow_accept(activity): + ''' hurray, someone remote accepted a follow request ''' + # figure out who they want to follow + requester = models.User.objects.get(actor=activity['object']['actor']) + # figure out who they are + accepter = get_or_create_remote_user(activity['actor']) + + accepter.followers.add(requester) + return HttpResponse() + + def handle_incoming_create(activity): ''' someone did something, good on them ''' user = get_or_create_remote_user(activity['actor']) diff --git a/fedireads/templates/user.html b/fedireads/templates/user.html index 416ca2014..f81f60f7b 100644 --- a/fedireads/templates/user.html +++ b/fedireads/templates/user.html @@ -10,7 +10,7 @@ {{ user.username }} {% if user.summary %} -
{{ user.summary }}
+
{{ user.summary | safe }}
{% endif %} {% if not is_self %} {% if not request.user in user.followers.all %}