From f7f8845801f3b65aed2d1d9a46d57659b91d6538 Mon Sep 17 00:00:00 2001 From: tamaina Date: Sun, 4 Jun 2023 15:05:01 +0000 Subject: [PATCH] wip --- .../src/server/api/endpoints/antennas/list.ts | 5 +- .../server/api/endpoints/antennas/notes.ts | 5 +- packages/misskey-js/src/endpoints.ts | 63 +++++++++++++++++-- 3 files changed, 64 insertions(+), 9 deletions(-) diff --git a/packages/backend/src/server/api/endpoints/antennas/list.ts b/packages/backend/src/server/api/endpoints/antennas/list.ts index a0f897957..c3c6ba23b 100644 --- a/packages/backend/src/server/api/endpoints/antennas/list.ts +++ b/packages/backend/src/server/api/endpoints/antennas/list.ts @@ -30,14 +30,15 @@ export const paramDef = { // eslint-disable-next-line import/no-default-export @Injectable() -export default class extends Endpoint { +export default class extends Endpoint<'antennas/list'> { + name = 'antennas/list' as const; constructor( @Inject(DI.antennasRepository) private antennasRepository: AntennasRepository, private antennaEntityService: AntennaEntityService, ) { - super(meta, paramDef, async (ps, me) => { + super(async (ps, me) => { const antennas = await this.antennasRepository.findBy({ userId: me.id, }); diff --git a/packages/backend/src/server/api/endpoints/antennas/notes.ts b/packages/backend/src/server/api/endpoints/antennas/notes.ts index e756a9b51..164d69f90 100644 --- a/packages/backend/src/server/api/endpoints/antennas/notes.ts +++ b/packages/backend/src/server/api/endpoints/antennas/notes.ts @@ -50,7 +50,8 @@ export const paramDef = { // eslint-disable-next-line import/no-default-export @Injectable() -export default class extends Endpoint { +export default class extends Endpoint<'antennas/notes'> { + name = 'antennas/notes' as const; constructor( @Inject(DI.redis) private redisClient: Redis.Redis, @@ -66,7 +67,7 @@ export default class extends Endpoint { private queryService: QueryService, private noteReadService: NoteReadService, ) { - super(meta, paramDef, async (ps, me) => { + super(async (ps, me) => { const antenna = await this.antennasRepository.findOneBy({ id: ps.antennaId, userId: me.id, diff --git a/packages/misskey-js/src/endpoints.ts b/packages/misskey-js/src/endpoints.ts index 48b557605..db7574a21 100644 --- a/packages/misskey-js/src/endpoints.ts +++ b/packages/misskey-js/src/endpoints.ts @@ -2032,16 +2032,16 @@ export const endpoints = { }, res: { $ref: 'https://misskey-hub.net/api/schemas/Antenna', - } + }, }], }, 'antennas/delete': { tags: ['antennas'], - + requireCredential: true, - + kind: 'write:account', - + errors: { noSuchAntenna: { message: 'No such antenna.', @@ -2060,7 +2060,60 @@ export const endpoints = { }, res: undefined, }], - } + }, + 'antennas/list': { + tags: ['antennas', 'account'], + + requireCredential: true, + + kind: 'read:account', + + defines: [{ + req: undefined, + res: { + type: 'array', + items: { + $ref: 'https://misskey-hub.net/api/schemas/Antenna', + }, + }, + }], + }, + 'antennas/notes': { + tags: ['antennas', 'account', 'notes'], + + requireCredential: true, + + kind: 'read:account', + + errors: { + noSuchAntenna: { + message: 'No such antenna.', + code: 'NO_SUCH_ANTENNA', + id: '850926e0-fd3b-49b6-b69a-b28a5dbd82fe', + }, + }, + + defines: [{ + req: { + type: 'object', + properties: { + antennaId: { type: 'string', format: 'misskey:id' }, + limit: { type: 'integer', minimum: 1, maximum: 100, default: 10 }, + sinceId: { type: 'string', format: 'misskey:id' }, + untilId: { type: 'string', format: 'misskey:id' }, + sinceDate: { type: 'integer' }, + untilDate: { type: 'integer' }, + }, + required: ['antennaId'], + }, + res: { + type: 'array', + items: { + $ref: 'https://misskey-hub.net/api/schemas/Note', + }, + }, + }], + }, //#endregion } as const satisfies { [x: string]: IEndpointMeta; };