summaryrefslogtreecommitdiff
path: root/internal/processing/federation
diff options
context:
space:
mode:
authorLibravatar Sleep <don@kuntz.co>2023-01-11 04:36:36 -0600
committerLibravatar GitHub <noreply@github.com>2023-01-11 11:36:36 +0100
commit3512325e4647fc76e6ce82ea44e2a321a0809451 (patch)
tree155643e96f98e66fac369a879317bb7e0b1efd31 /internal/processing/federation
parent[feature] Implement Report database model and utility functions (#1310) (diff)
downloadgotosocial-3512325e4647fc76e6ce82ea44e2a321a0809451.tar.xz
[feature] Add local user and post count to nodeinfo responses (#1325)
* Add local user and post count to nodeinfo responses This fixes #1307 (at least partially). The nodeinfo endpoint should now return the total users on an instance, along with their post count. * Update NodeInfoUsers docstring and swagger yaml file
Diffstat (limited to 'internal/processing/federation')
-rw-r--r--internal/processing/federation/getnodeinfo.go16
1 files changed, 15 insertions, 1 deletions
diff --git a/internal/processing/federation/getnodeinfo.go b/internal/processing/federation/getnodeinfo.go
index ff7aea649..a15c6fa10 100644
--- a/internal/processing/federation/getnodeinfo.go
+++ b/internal/processing/federation/getnodeinfo.go
@@ -55,6 +55,17 @@ func (p *processor) GetNodeInfo(ctx context.Context) (*apimodel.Nodeinfo, gtserr
openRegistration := config.GetAccountsRegistrationOpen()
softwareVersion := config.GetSoftwareVersion()
+ host := config.GetHost()
+ userCount, err := p.db.CountInstanceUsers(ctx, host)
+ if err != nil {
+ return nil, gtserror.NewErrorInternalError(err, "Unable to query instance user count")
+ }
+
+ postCount, err := p.db.CountInstanceStatuses(ctx, host)
+ if err != nil {
+ return nil, gtserror.NewErrorInternalError(err, "Unable to query instance status count")
+ }
+
return &apimodel.Nodeinfo{
Version: nodeInfoVersion,
Software: apimodel.NodeInfoSoftware{
@@ -68,7 +79,10 @@ func (p *processor) GetNodeInfo(ctx context.Context) (*apimodel.Nodeinfo, gtserr
},
OpenRegistrations: openRegistration,
Usage: apimodel.NodeInfoUsage{
- Users: apimodel.NodeInfoUsers{},
+ Users: apimodel.NodeInfoUsers{
+ Total: userCount,
+ },
+ LocalPosts: postCount,
},
Metadata: make(map[string]interface{}),
}, nil