From 1262c619bbfe779c0902f42bcc2d975d7cd2937b Mon Sep 17 00:00:00 2001 From: Henri Dickson <90480431+alphatownsman@users.noreply.github.com> Date: Fri, 11 Aug 2023 11:34:25 -0400 Subject: [PATCH] Make nodeinfo do metadata based on domain requested (#628) --- users/views/activitypub.py | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/users/views/activitypub.py b/users/views/activitypub.py index afc317f..461840e 100644 --- a/users/views/activitypub.py +++ b/users/views/activitypub.py @@ -72,8 +72,19 @@ class NodeInfo2(View): def get(self, request): # Fetch some user stats - local_identities = Identity.objects.filter(local=True).count() - local_posts = Post.objects.filter(local=True).count() + if request.domain: + domain_config = Config.load_domain(request.domain) + local_identities = Identity.objects.filter( + local=True, domain=request.domain + ).count() + local_posts = Post.objects.filter( + local=True, author__domain=request.domain + ).count() + metadata = {"nodeName": domain_config.site_name} + else: + local_identities = Identity.objects.filter(local=True).count() + local_posts = Post.objects.filter(local=True).count() + metadata = {} return JsonResponse( { "version": "2.0", @@ -85,7 +96,7 @@ class NodeInfo2(View): "localPosts": local_posts, }, "openRegistrations": Config.system.signup_allowed, - "metadata": {}, + "metadata": metadata, } )