mirror of
https://github.com/jointakahe/takahe.git
synced 2024-11-26 01:01:00 +00:00
Make nodeinfo do metadata based on domain requested (#628)
This commit is contained in:
parent
0c72327ab7
commit
1262c619bb
1 changed files with 14 additions and 3 deletions
|
@ -72,8 +72,19 @@ class NodeInfo2(View):
|
||||||
|
|
||||||
def get(self, request):
|
def get(self, request):
|
||||||
# Fetch some user stats
|
# Fetch some user stats
|
||||||
|
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_identities = Identity.objects.filter(local=True).count()
|
||||||
local_posts = Post.objects.filter(local=True).count()
|
local_posts = Post.objects.filter(local=True).count()
|
||||||
|
metadata = {}
|
||||||
return JsonResponse(
|
return JsonResponse(
|
||||||
{
|
{
|
||||||
"version": "2.0",
|
"version": "2.0",
|
||||||
|
@ -85,7 +96,7 @@ class NodeInfo2(View):
|
||||||
"localPosts": local_posts,
|
"localPosts": local_posts,
|
||||||
},
|
},
|
||||||
"openRegistrations": Config.system.signup_allowed,
|
"openRegistrations": Config.system.signup_allowed,
|
||||||
"metadata": {},
|
"metadata": metadata,
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue