diff --git a/packages/backend/src/server/api/endpoints/antennas/update.ts b/packages/backend/src/server/api/endpoints/antennas/update.ts index 5f980bdbe..9f25ff464 100644 --- a/packages/backend/src/server/api/endpoints/antennas/update.ts +++ b/packages/backend/src/server/api/endpoints/antennas/update.ts @@ -6,67 +6,10 @@ import { AntennaEntityService } from '@/core/entities/AntennaEntityService.js'; import { DI } from '@/di-symbols.js'; import { ApiError } from '../../error.js'; -export const meta = { - tags: ['antennas'], - - requireCredential: true, - - prohibitMoved: true, - - kind: 'write:account', - - errors: { - noSuchAntenna: { - message: 'No such antenna.', - code: 'NO_SUCH_ANTENNA', - id: '10c673ac-8852-48eb-aa1f-f5b67f069290', - }, - - noSuchUserList: { - message: 'No such user list.', - code: 'NO_SUCH_USER_LIST', - id: '1c6b35c9-943e-48c2-81e4-2844989407f7', - }, - }, - - res: { - type: 'object', - optional: false, nullable: false, - ref: 'Antenna', - }, -} as const; - -export const paramDef = { - type: 'object', - properties: { - antennaId: { type: 'string', format: 'misskey:id' }, - name: { type: 'string', minLength: 1, maxLength: 100 }, - src: { type: 'string', enum: ['home', 'all', 'users', 'list'] }, - userListId: { type: 'string', format: 'misskey:id', nullable: true }, - 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: ['antennaId', 'name', 'src', 'keywords', 'excludeKeywords', 'users', 'caseSensitive', 'withReplies', 'withFile', 'notify'], -} as const; - // eslint-disable-next-line import/no-default-export @Injectable() -export default class extends Endpoint { +export default class extends Endpoint<'antennas/update'> { + name = 'antennas/update' as const; constructor( @Inject(DI.antennasRepository) private antennasRepository: AntennasRepository, @@ -77,7 +20,7 @@ export default class extends Endpoint { private antennaEntityService: AntennaEntityService, private globalEventService: GlobalEventService, ) { - super(meta, paramDef, async (ps, me) => { + super(async (ps, me) => { // Fetch the antenna const antenna = await this.antennasRepository.findOneBy({ id: ps.antennaId, @@ -85,7 +28,7 @@ export default class extends Endpoint { }); if (antenna == null) { - throw new ApiError(meta.errors.noSuchAntenna); + throw new ApiError(this.meta.errors.noSuchAntenna); } let userList; @@ -97,7 +40,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 9a14004b8..ba4a557db 100644 --- a/packages/misskey-js/src/endpoints.ts +++ b/packages/misskey-js/src/endpoints.ts @@ -2142,6 +2142,67 @@ export const endpoints = { }, }], }, + 'antennas/update': { + tags: ['antennas'], + + requireCredential: true, + + prohibitMoved: true, + + kind: 'write:account', + + errors: { + noSuchAntenna: { + message: 'No such antenna.', + code: 'NO_SUCH_ANTENNA', + id: '10c673ac-8852-48eb-aa1f-f5b67f069290', + }, + + noSuchUserList: { + message: 'No such user list.', + code: 'NO_SUCH_USER_LIST', + id: '1c6b35c9-943e-48c2-81e4-2844989407f7', + }, + }, + + defines: [{ + req: { + type: 'object', + properties: { + antennaId: { type: 'string', format: 'misskey:id' }, + 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: ['antennaId', '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; };