mirror of
https://github.com/superseriousbusiness/gotosocial
synced 2025-06-05 21:59:39 +02:00
[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
This commit is contained in:
@ -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
|
||||
|
Reference in New Issue
Block a user