diff --git a/packages/backend/src/server/api/endpoints/antennas/create.ts b/packages/backend/src/server/api/endpoints/antennas/create.ts index 5754a9f12a..766ad1ae38 100644 --- a/packages/backend/src/server/api/endpoints/antennas/create.ts +++ b/packages/backend/src/server/api/endpoints/antennas/create.ts @@ -8,36 +8,6 @@ import { DI } from '@/di-symbols.js'; import { RoleService } from '@/core/RoleService.js'; import { ApiError } from '../../error.js'; -export const meta = { - tags: ['antennas'], - - requireCredential: true, - - prohibitMoved: true, - - kind: 'write:account', - - errors: { - noSuchUserList: { - message: 'No such user list.', - code: 'NO_SUCH_USER_LIST', - id: '95063e93-a283-4b8b-9aa5-bcdb8df69a7f', - }, - - tooManyAntennas: { - message: 'You cannot create antenna any more.', - code: 'TOO_MANY_ANTENNAS', - id: 'faf47050-e8b5-438c-913c-db2b1576fde4', - }, - }, - - res: { - type: 'object', - optional: false, nullable: false, - ref: 'Antenna', - }, -} as const; - export const paramDef = { type: 'object', properties: { @@ -67,7 +37,8 @@ export const paramDef = { // eslint-disable-next-line import/no-default-export @Injectable() -export default class extends Endpoint { +export default class extends Endpoint<'antenna/create'> { + name = 'antenna/create' as const; constructor( @Inject(DI.antennasRepository) private antennasRepository: AntennasRepository, @@ -80,7 +51,7 @@ export default class extends Endpoint { private idService: IdService, private globalEventService: GlobalEventService, ) { - super(meta, paramDef, async (ps, me) => { + super(async (ps, me) => { if ((ps.keywords.length === 0) || ps.keywords[0].every(x => x === '')) { throw new Error('invalid param'); } @@ -89,7 +60,7 @@ export default class extends Endpoint { userId: me.id, }); if (currentAntennasCount > (await this.roleService.getUserPolicies(me.id)).antennaLimit) { - throw new ApiError(meta.errors.tooManyAntennas); + throw new ApiError(this.meta.errors.tooManyAntennas); } let userList; @@ -101,7 +72,7 @@ export default class extends Endpoint { }); if (userList == null) { - throw new ApiError(meta.errors.noSuchUserList); + throw new ApiError(this.meta.errors.noSuchUserList); } } diff --git a/packages/misskey-js/src/endpoints.ts b/packages/misskey-js/src/endpoints.ts index c5272f7921..eb43830bf1 100644 --- a/packages/misskey-js/src/endpoints.ts +++ b/packages/misskey-js/src/endpoints.ts @@ -1969,6 +1969,72 @@ export const endpoints = { //#endregion //#region antenna + 'antenna/create': { + tags: ['antennas'], + + requireCredential: true, + + prohibitMoved: true, + + kind: 'write:account', + + errors: { + noSuchUserList: { + message: 'No such user list.', + code: 'NO_SUCH_USER_LIST', + id: '95063e93-a283-4b8b-9aa5-bcdb8df69a7f', + }, + + tooManyAntennas: { + message: 'You cannot create antenna any more.', + code: 'TOO_MANY_ANTENNAS', + id: 'faf47050-e8b5-438c-913c-db2b1576fde4', + }, + }, + + defines: [{ + req: { + type: 'object', + properties: { + name: { type: 'string', minLength: 1, maxLength: 100 }, + src: { type: 'string', enum: ['home', 'all', 'users', 'list'] }, + userListId: { + oneOf: [ + { type: 'string', format: 'misskey:id' }, + { type: 'null' }, + ], + }, + keywords: { + type: 'array', items: { + type: 'array', items: { + type: 'string', + }, + } + }, + excludeKeywords: { + type: 'array', items: { + type: 'array', items: { + type: 'string', + }, + } + }, + users: { + type: 'array', items: { + type: 'string', + } + }, + caseSensitive: { type: 'boolean' }, + withReplies: { type: 'boolean' }, + withFile: { type: 'boolean' }, + notify: { type: 'boolean' }, + }, + required: ['name', 'src', 'keywords', 'excludeKeywords', 'users', 'caseSensitive', 'withReplies', 'withFile', 'notify'], + }, + res: { + $ref: 'https://misskey-hub.net/api/schemas/Antenna', + } + }], + }, //#endregion } as const satisfies { [x: string]: IEndpointMeta; };