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

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