summaryrefslogtreecommitdiff
path: root/internal
diff options
context:
space:
mode:
Diffstat (limited to 'internal')
-rw-r--r--internal/api/model/well-known.go9
-rw-r--r--internal/processing/federation/getnodeinfo.go16
2 files changed, 21 insertions, 4 deletions
diff --git a/internal/api/model/well-known.go b/internal/api/model/well-known.go
index 384361fd0..bf61a6085 100644
--- a/internal/api/model/well-known.go
+++ b/internal/api/model/well-known.go
@@ -79,8 +79,11 @@ type NodeInfoServices struct {
// NodeInfoUsage represents usage information about this server, such as number of users.
type NodeInfoUsage struct {
- Users NodeInfoUsers `json:"users"`
+ Users NodeInfoUsers `json:"users"`
+ LocalPosts int `json:"localPosts"`
}
-// NodeInfoUsers is a stub for usage information, currently empty.
-type NodeInfoUsers struct{}
+// NodeInfoUsers represents aggregate information about the users on the server.
+type NodeInfoUsers struct {
+ Total int `json:"total"`
+}
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