From 42990fe6b67394d3bbedc35f901df161cb02b65b Mon Sep 17 00:00:00 2001 From: tamaina Date: Mon, 3 Jul 2023 05:45:38 +0000 Subject: [PATCH] wip --- .../src/server/api/endpoints/flash/create.ts | 36 ++---------------- packages/misskey-js/src/endpoints.ts | 38 +++++++++++++++++++ 2 files changed, 41 insertions(+), 33 deletions(-) diff --git a/packages/backend/src/server/api/endpoints/flash/create.ts b/packages/backend/src/server/api/endpoints/flash/create.ts index 3172bdbfd..828c3d860 100644 --- a/packages/backend/src/server/api/endpoints/flash/create.ts +++ b/packages/backend/src/server/api/endpoints/flash/create.ts @@ -6,40 +6,10 @@ import { Endpoint } from '@/server/api/endpoint-base.js'; import { DI } from '@/di-symbols.js'; import { FlashEntityService } from '@/core/entities/FlashEntityService.js'; -export const meta = { - tags: ['flash'], - - requireCredential: true, - - prohibitMoved: true, - - kind: 'write:flash', - - limit: { - duration: ms('1hour'), - max: 10, - }, - - errors: { - }, -} as const; - -export const paramDef = { - type: 'object', - properties: { - title: { type: 'string' }, - summary: { type: 'string' }, - script: { type: 'string' }, - permissions: { type: 'array', items: { - type: 'string', - } }, - }, - required: ['title', 'summary', 'script', 'permissions'], -} as const; - // eslint-disable-next-line import/no-default-export @Injectable() -export default class extends Endpoint { +export default class extends Endpoint<'flash/create'> { + name = 'flash/create' as const; constructor( @Inject(DI.flashsRepository) private flashsRepository: FlashsRepository, @@ -47,7 +17,7 @@ export default class extends Endpoint { private flashEntityService: FlashEntityService, private idService: IdService, ) { - super(meta, paramDef, async (ps, me) => { + super(async (ps, me) => { const flash = await this.flashsRepository.insert({ id: this.idService.genId(), userId: me.id, diff --git a/packages/misskey-js/src/endpoints.ts b/packages/misskey-js/src/endpoints.ts index 0f9217613..9fb1a248b 100644 --- a/packages/misskey-js/src/endpoints.ts +++ b/packages/misskey-js/src/endpoints.ts @@ -4412,6 +4412,44 @@ export const endpoints = { }], }, //#endregion + + //#region flash + 'flash/create': { + tags: ['flash'], + + requireCredential: true, + + prohibitMoved: true, + + kind: 'write:flash', + + limit: { + duration: ms('1hour'), + max: 10, + }, + + errors: { + }, + + defines: [{ + req: { + type: 'object', + properties: { + title: { type: 'string' }, + summary: { type: 'string' }, + script: { type: 'string' }, + permissions: { type: 'array', items: { + type: 'string', + } }, + }, + required: ['title', 'summary', 'script', 'permissions'], + }, + res: { + $ref: 'https://misskey-hub.net/api/schemas/Flash', + }, + }] + }, + //#endregion } as const satisfies { [x: string]: IEndpointMeta; }; /**