This commit is contained in:
tamaina 2023-05-29 17:16:53 +00:00
parent 3918473e29
commit 90a22fe32f
3 changed files with 43 additions and 46 deletions

View File

@ -6,45 +6,10 @@ import { UserEntityService } from '@/core/entities/UserEntityService.js';
import { sqlLikeEscape } from '@/misc/sql-like-escape.js'; import { sqlLikeEscape } from '@/misc/sql-like-escape.js';
import { RoleService } from '@/core/RoleService.js'; import { RoleService } from '@/core/RoleService.js';
export const meta = {
tags: ['admin'],
requireCredential: true,
requireModerator: true,
res: {
type: 'array',
nullable: false, optional: false,
items: {
type: 'object',
nullable: false, optional: false,
ref: 'UserDetailed',
},
},
} as const;
export const paramDef = {
type: 'object',
properties: {
limit: { type: 'integer', minimum: 1, maximum: 100, default: 10 },
offset: { type: 'integer', default: 0 },
sort: { type: 'string', enum: ['+follower', '-follower', '+createdAt', '-createdAt', '+updatedAt', '-updatedAt', '+lastActiveDate', '-lastActiveDate'] },
state: { type: 'string', enum: ['all', 'alive', 'available', 'admin', 'moderator', 'adminOrModerator', 'suspended'], default: 'all' },
origin: { type: 'string', enum: ['combined', 'local', 'remote'], default: 'combined' },
username: { type: 'string', nullable: true, default: null },
hostname: {
type: 'string',
nullable: true,
default: null,
description: 'The local host is represented with `null`.',
},
},
required: [],
} as const;
// eslint-disable-next-line import/no-default-export // eslint-disable-next-line import/no-default-export
@Injectable() @Injectable()
export default class extends Endpoint<typeof meta, typeof paramDef> { export default class extends Endpoint<'admin/show-users'> {
name = 'admin/show-users' as const;
constructor( constructor(
@Inject(DI.usersRepository) @Inject(DI.usersRepository)
private usersRepository: UsersRepository, private usersRepository: UsersRepository,
@ -52,7 +17,7 @@ export default class extends Endpoint<typeof meta, typeof paramDef> {
private userEntityService: UserEntityService, private userEntityService: UserEntityService,
private roleService: RoleService, private roleService: RoleService,
) { ) {
super(meta, paramDef, async (ps, me) => { super(async (ps, me) => {
const query = this.usersRepository.createQueryBuilder('user'); const query = this.usersRepository.createQueryBuilder('user');
switch (ps.state) { switch (ps.state) {

View File

@ -1588,7 +1588,7 @@ export const endpoints = {
properties: { properties: {
reportId: { type: 'string', format: 'misskey:id' }, reportId: { type: 'string', format: 'misskey:id' },
forward: { type: 'boolean', default: false }, forward: { type: 'boolean', default: false },
}, } satisfies Record<string, JSONSchema7>,
required: ['reportId'], required: ['reportId'],
}, },
res: undefined, res: undefined,
@ -1639,7 +1639,7 @@ export const endpoints = {
limit: { type: 'integer', minimum: 1, maximum: 100, default: 10 }, limit: { type: 'integer', minimum: 1, maximum: 100, default: 10 },
sinceId: { type: 'string', format: 'misskey:id' }, sinceId: { type: 'string', format: 'misskey:id' },
untilId: { type: 'string', format: 'misskey:id' }, untilId: { type: 'string', format: 'misskey:id' },
}, } satisfies Record<string, JSONSchema7>,
required: [], required: [],
}, },
res: { res: {
@ -1725,7 +1725,7 @@ export const endpoints = {
$ref: 'https://misskey-hub.net/api/schemas/Role', $ref: 'https://misskey-hub.net/api/schemas/Role',
} }
}, },
}, } satisfies Record<string, JSONSchema7>,
required: [ required: [
'email', 'email',
'emailVerified', 'emailVerified',
@ -1752,6 +1752,38 @@ export const endpoints = {
} }
}], }],
}, },
'admin/show-users': {
tags: ['admin'],
requireCredential: true,
requireModerator: true,
defines: [{
req: {
type: 'object',
properties: {
limit: { type: 'integer', minimum: 1, maximum: 100, default: 10 },
offset: { type: 'integer', default: 0 },
sort: { type: 'string', enum: ['+follower', '-follower', '+createdAt', '-createdAt', '+updatedAt', '-updatedAt', '+lastActiveDate', '-lastActiveDate'] },
state: { type: 'string', enum: ['all', 'alive', 'available', 'admin', 'moderator', 'adminOrModerator', 'suspended'], default: 'all' },
origin: { type: 'string', enum: ['combined', 'local', 'remote'], default: 'combined' },
username: { type: ['string', 'null'], default: null },
hostname: {
type: ['string', 'null'],
default: null,
description: 'The local host is represented with `null`.',
},
} satisfies Record<string, JSONSchema7>,
required: [],
},
res: {
type: 'array',
items: {
$ref: 'https://misskey-hub.net/api/schemas/UserDetailed',
},
}
}],
}
} as const satisfies { [x: string]: IEndpointMeta; }; } as const satisfies { [x: string]: IEndpointMeta; };
/** /**

View File

@ -630,7 +630,7 @@ importers:
version: 29.5.0 version: 29.5.0
schema-type: schema-type:
specifier: github:misskey-dev/schema-type specifier: github:misskey-dev/schema-type
version: github.com/misskey-dev/schema-type/d4ff8d1c43883a0facacc9ec47ec50aa239828bc(typescript@5.0.4) version: github.com/misskey-dev/schema-type/65413af4ef676dafb5d06ebc04dce39c74b3a8f9(typescript@5.0.4)
packages/frontend: packages/frontend:
dependencies: dependencies:
@ -1030,7 +1030,7 @@ importers:
version: 4.4.0 version: 4.4.0
schema-type: schema-type:
specifier: github:misskey-dev/schema-type specifier: github:misskey-dev/schema-type
version: github.com/misskey-dev/schema-type/d4ff8d1c43883a0facacc9ec47ec50aa239828bc(typescript@5.0.4) version: github.com/misskey-dev/schema-type/65413af4ef676dafb5d06ebc04dce39c74b3a8f9(typescript@5.0.4)
ts-essentials: ts-essentials:
specifier: ^9.3.2 specifier: ^9.3.2
version: 9.3.2(typescript@5.0.4) version: 9.3.2(typescript@5.0.4)
@ -20557,9 +20557,9 @@ packages:
version: 0.0.0 version: 0.0.0
dev: false dev: false
github.com/misskey-dev/schema-type/d4ff8d1c43883a0facacc9ec47ec50aa239828bc(typescript@5.0.4): github.com/misskey-dev/schema-type/65413af4ef676dafb5d06ebc04dce39c74b3a8f9(typescript@5.0.4):
resolution: {tarball: https://codeload.github.com/misskey-dev/schema-type/tar.gz/d4ff8d1c43883a0facacc9ec47ec50aa239828bc} resolution: {tarball: https://codeload.github.com/misskey-dev/schema-type/tar.gz/65413af4ef676dafb5d06ebc04dce39c74b3a8f9}
id: github.com/misskey-dev/schema-type/d4ff8d1c43883a0facacc9ec47ec50aa239828bc id: github.com/misskey-dev/schema-type/65413af4ef676dafb5d06ebc04dce39c74b3a8f9
name: schema-type name: schema-type
version: 1.0.0 version: 1.0.0
dependencies: dependencies: