diff --git a/packages/backend/src/server/api/endpoints/admin/reset-password.ts b/packages/backend/src/server/api/endpoints/admin/reset-password.ts index d263f99f6e..77b0c1a14b 100644 --- a/packages/backend/src/server/api/endpoints/admin/reset-password.ts +++ b/packages/backend/src/server/api/endpoints/admin/reset-password.ts @@ -5,37 +5,10 @@ import { Endpoint } from '@/server/api/endpoint-base.js'; import type { UsersRepository, UserProfilesRepository } from '@/models/index.js'; import { DI } from '@/di-symbols.js'; -export const meta = { - tags: ['admin'], - - requireCredential: true, - requireModerator: true, - - res: { - type: 'object', - optional: false, nullable: false, - properties: { - password: { - type: 'string', - optional: false, nullable: false, - minLength: 8, - maxLength: 8, - }, - }, - }, -} as const; - -export const paramDef = { - type: 'object', - properties: { - userId: { type: 'string', format: 'misskey:id' }, - }, - required: ['userId'], -} as const; - // eslint-disable-next-line import/no-default-export @Injectable() -export default class extends Endpoint { +export default class extends Endpoint<'admin/reset-password'> { + name = 'admin/reset-password' as const; constructor( @Inject(DI.usersRepository) private usersRepository: UsersRepository, @@ -43,7 +16,7 @@ export default class extends Endpoint { @Inject(DI.userProfilesRepository) private userProfilesRepository: UserProfilesRepository, ) { - super(meta, paramDef, async (ps) => { + super(async (ps) => { const user = await this.usersRepository.findOneBy({ id: ps.userId }); if (user == null) { diff --git a/packages/backend/src/server/api/endpoints/admin/resolve-abuse-user-report.ts b/packages/backend/src/server/api/endpoints/admin/resolve-abuse-user-report.ts index aead894611..b3f94c17e0 100644 --- a/packages/backend/src/server/api/endpoints/admin/resolve-abuse-user-report.ts +++ b/packages/backend/src/server/api/endpoints/admin/resolve-abuse-user-report.ts @@ -6,27 +6,12 @@ import { QueueService } from '@/core/QueueService.js'; import { ApRendererService } from '@/core/activitypub/ApRendererService.js'; import { DI } from '@/di-symbols.js'; -export const meta = { - tags: ['admin'], - - requireCredential: true, - requireModerator: true, -} as const; - -export const paramDef = { - type: 'object', - properties: { - reportId: { type: 'string', format: 'misskey:id' }, - forward: { type: 'boolean', default: false }, - }, - required: ['reportId'], -} as const; - // TODO: ロジックをサービスに切り出す // eslint-disable-next-line import/no-default-export @Injectable() -export default class extends Endpoint { +export default class extends Endpoint<'admin/resolve-abuse-user-report'> { + name = 'admin/resolve-abuse-user-report' as const; constructor( @Inject(DI.usersRepository) private usersRepository: UsersRepository, @@ -38,7 +23,7 @@ export default class extends Endpoint { private instanceActorService: InstanceActorService, private apRendererService: ApRendererService, ) { - super(meta, paramDef, async (ps, me) => { + super(async (ps, me) => { const report = await this.abuseUserReportsRepository.findOneBy({ id: ps.reportId }); if (report == null) { diff --git a/packages/backend/src/server/api/endpoints/admin/send-email.ts b/packages/backend/src/server/api/endpoints/admin/send-email.ts index 5ddc62f476..c45d7f98c9 100644 --- a/packages/backend/src/server/api/endpoints/admin/send-email.ts +++ b/packages/backend/src/server/api/endpoints/admin/send-email.ts @@ -2,30 +2,14 @@ import { Injectable } from '@nestjs/common'; import { Endpoint } from '@/server/api/endpoint-base.js'; import { EmailService } from '@/core/EmailService.js'; -export const meta = { - tags: ['admin'], - - requireCredential: true, - requireModerator: true, -} as const; - -export const paramDef = { - type: 'object', - properties: { - to: { type: 'string' }, - subject: { type: 'string' }, - text: { type: 'string' }, - }, - required: ['to', 'subject', 'text'], -} as const; - // eslint-disable-next-line import/no-default-export @Injectable() -export default class extends Endpoint { +export default class extends Endpoint<'admin/send-email'> { + name = 'admin/send-email' as const; constructor( private emailService: EmailService, ) { - super(meta, paramDef, async (ps, me) => { + super(async (ps, me) => { await this.emailService.sendEmail(ps.to, ps.subject, ps.text, ps.text); }); } diff --git a/packages/misskey-js/src/endpoints.ts b/packages/misskey-js/src/endpoints.ts index 5ff1173902..def244224a 100644 --- a/packages/misskey-js/src/endpoints.ts +++ b/packages/misskey-js/src/endpoints.ts @@ -1470,7 +1470,7 @@ export const endpoints = { 'admin/get-index-stats': { requireCredential: true, requireAdmin: true, - + tags: ['admin'], defines: [{ @@ -1491,9 +1491,9 @@ export const endpoints = { 'admin/get-table-stats': { requireCredential: true, requireAdmin: true, - + tags: ['admin'], - + defines: [{ req: undefined, res: { @@ -1511,7 +1511,7 @@ export const endpoints = { }, 'admin/get-user-ips': { tags: ['admin'], - + requireCredential: true, requireModerator: true, @@ -1538,7 +1538,7 @@ export const endpoints = { }, 'admin/meta': { tags: ['meta'], - + requireCredential: true, requireAdmin: true, @@ -1548,7 +1548,71 @@ export const endpoints = { $ref: 'https://misskey-hub.net/api/schemas/InstanceMetaAdmin', }, }], - } + }, + 'admin/reset-password': { + tags: ['admin'], + + requireCredential: true, + requireModerator: true, + + defines: [{ + req: { + type: 'object', + properties: { + userId: { type: 'string', format: 'misskey:id' }, + }, + required: ['userId'], + }, + res: { + type: 'object', + properties: { + password: { + type: 'string', + minLength: 8, + maxLength: 8, + }, + }, + required: ['password'], + }, + }], + }, + 'admin/resolve-abuse-user-report': { + tags: ['admin'], + + requireCredential: true, + requireModerator: true, + + defines: [{ + req: { + type: 'object', + properties: { + reportId: { type: 'string', format: 'misskey:id' }, + forward: { type: 'boolean', default: false }, + }, + required: ['reportId'], + }, + res: undefined, + }], + }, + 'admin/send-email': { + tags: ['admin'], + + requireCredential: true, + requireModerator: true, + + defines: [{ + req: { + type: 'object', + properties: { + to: { type: 'string' }, + subject: { type: 'string' }, + text: { type: 'string' }, + }, + required: ['to', 'subject', 'text'], + }, + res: undefined, + }], + }, } as const satisfies { [x: string]: IEndpointMeta; }; /**