More nodeinfo endpoints

This commit is contained in:
Mouse Reeve 2020-02-15 11:40:21 -08:00
parent cea458acdd
commit 1e25c2f869
2 changed files with 32 additions and 3 deletions

View file

@ -20,7 +20,8 @@ urlpatterns = [
# .well-known endpoints
re_path(r'^.well-known/webfinger/?$', wellknown.webfinger),
re_path(r'^.well-known/nodeinfo/?$', wellknown.nodeinfo),
re_path(r'^.well-known/nodeinfo/?$', wellknown.nodeinfo_pointer),
re_path(r'^nodeinfo/2\.0/?$', wellknown.nodeinfo),
re_path(r'^api/v1/instance/?$', wellknown.instance_info),
# TODO: re_path(r'^.well-known/host-meta/?$', incoming.host_meta),

View file

@ -30,8 +30,8 @@ def webfinger(request):
})
def nodeinfo(request):
''' idk what this is, but mastodon asked for it '''
def nodeinfo_pointer(request):
''' direct servers to nodeinfo '''
if request.method != 'GET':
return HttpResponseNotFound()
@ -44,6 +44,34 @@ def nodeinfo(request):
]
})
def nodeinfo(request):
''' basic info about the server '''
if request.method != 'GET':
return HttpResponseNotFound()
status_count = models.Status.objects.count()
user_count = models.User.objects.count()
return JsonResponse({
"version": "2.0",
"software": {
"name": "mastodon",
"version": "3.0.1"
},
"protocols": [
"activitypub"
],
"usage": {
"users": {
"total": user_count,
"activeMonth": user_count, # TODO
"activeHalfyear": user_count, # TODO
},
"localPosts": status_count, # TODO: mark local
},
"openRegistrations": True,
})
def instance_info(request):
''' what this place is TODO: should be settable/editable '''