From f8989f58ae9191ae0551d596e98c74c21de374a1 Mon Sep 17 00:00:00 2001 From: Romain Gauthier Date: Sat, 22 Jul 2017 16:55:58 +0200 Subject: [PATCH] Implement the followers endpoint. GET /@/followers --- activitypub/urls.py | 1 + activitypub/views.py | 7 +++++++ 2 files changed, 8 insertions(+) diff --git a/activitypub/urls.py b/activitypub/urls.py index 6a8519d..b41ab23 100644 --- a/activitypub/urls.py +++ b/activitypub/urls.py @@ -7,6 +7,7 @@ from activitypub.views import followers, noop urlpatterns = [ url(r'^@(\w+)/notes/(\w+)', note, name="note"), url(r'^@(\w+)/notes', notes, name="notes"), + url(r'^@(\w+)/followers', followers, name="followers"), url(r'^@(\w+)/outbox', outbox, name="outbox"), url(r'^@([^/]+)$', person, name="person"), url(r'^admin/', admin.site.urls), diff --git a/activitypub/views.py b/activitypub/views.py index 9e255e4..af5b2ba 100644 --- a/activitypub/views.py +++ b/activitypub/views.py @@ -65,3 +65,10 @@ def notes(request, username): # ) return JsonResponse(collection.to_json(context=True)) +def followers(request, username): + person = get_object_or_404(Person, username=username) + followers = activities.OrderedCollection(person.followers.all()) + actor = activities.Person(id="http://bob.local/@bob",name="Bob") + followers.items.append(actor) + return JsonResponse(followers.to_json(context=True)) +