4
4
*/
5
5
6
6
import { Inject , Injectable } from '@nestjs/common' ;
7
+ import { In , IsNull , Not } from 'typeorm' ;
7
8
import { Endpoint } from '@/server/api/endpoint-base.js' ;
8
9
import { MetaService } from '@/core/MetaService.js' ;
9
10
import type { Config } from '@/config.js' ;
10
11
import { DI } from '@/di-symbols.js' ;
11
12
import { DEFAULT_POLICIES } from '@/core/RoleService.js' ;
12
13
import { envOption } from '@/env.js' ;
14
+ import type { UsersRepository } from '@/models/_.js' ;
13
15
14
16
export const meta = {
15
17
tags : [ 'meta' ] ,
@@ -644,6 +646,9 @@ export const meta = {
644
646
iconDark : { type : 'string' , nullable : true } ,
645
647
bannerLight : { type : 'string' , nullable : true } ,
646
648
bannerDark : { type : 'string' , nullable : true } ,
649
+ maxLocalUsers : { type : 'number' , nullable : true } ,
650
+ nowLocalUsers : { type : 'number' , nullable : true } ,
651
+ isManaged : { type : 'boolean' , nullable : true } ,
647
652
} ,
648
653
} ,
649
654
} as const ;
@@ -659,6 +664,8 @@ export default class extends Endpoint<typeof meta, typeof paramDef> {
659
664
constructor (
660
665
@Inject ( DI . config )
661
666
private config : Config ,
667
+ @Inject ( DI . usersRepository )
668
+ private usersRepository : UsersRepository ,
662
669
private metaService : MetaService ,
663
670
) {
664
671
super ( meta , paramDef , async ( _ , me ) => {
@@ -787,6 +794,8 @@ export default class extends Endpoint<typeof meta, typeof paramDef> {
787
794
urlPreviewRequireContentLength : instance . urlPreviewRequireContentLength ,
788
795
urlPreviewUserAgent : instance . urlPreviewUserAgent ,
789
796
urlPreviewSummaryProxyUrl : instance . urlPreviewSummaryProxyUrl ,
797
+ maxLocalUsers : 0 ,
798
+ nowLocalUsers : 0 ,
790
799
} ;
791
800
792
801
if ( ! envOption . managed || this . config . rootUserName === me . username ) {
@@ -807,6 +816,8 @@ export default class extends Endpoint<typeof meta, typeof paramDef> {
807
816
objectStorageUseProxy : false ,
808
817
objectStorageSetPublicRead : false ,
809
818
objectStorageS3ForcePathStyle : false ,
819
+ maxLocalUsers : this . config . maxLocalUsers ,
820
+ nowLocalUsers : await this . usersRepository . count ( { where : { host : IsNull ( ) , username : Not ( In ( [ 'instance.actor' , 'relay.actor' , this . config . adminUserName , this . config . rootUserName ] ) ) } } ) ,
810
821
summalyProxy : 'Masked' ,
811
822
deeplAuthKey : 'Masked' ,
812
823
isManaged : true ,
0 commit comments