diff --git a/fedireads/urls.py b/fedireads/urls.py index 8767d2505..3cbeb5246 100644 --- a/fedireads/urls.py +++ b/fedireads/urls.py @@ -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), diff --git a/fedireads/wellknown.py b/fedireads/wellknown.py index 541c1dc20..a0a4ec8e7 100644 --- a/fedireads/wellknown.py +++ b/fedireads/wellknown.py @@ -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 '''