Handle follow request accept activities

This commit is contained in:
Mouse Reeve 2020-02-14 20:24:35 -08:00
parent 4f60d27c12
commit 48d92f1990
2 changed files with 13 additions and 3 deletions

View file

@ -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'])

View file

@ -10,7 +10,7 @@
<small>{{ user.username }}</small>
</h2>
{% if user.summary %}
<blockquote>{{ user.summary }}</blockquote>
<blockquote>{{ user.summary | safe }}</blockquote>
{% endif %}
{% if not is_self %}
{% if not request.user in user.followers.all %}