diff --git a/packages/backend/src/server/api/endpoints/drive/files/attached-notes.ts b/packages/backend/src/server/api/endpoints/drive/files/attached-notes.ts index 4c4fb1ad0..2958eda65 100644 --- a/packages/backend/src/server/api/endpoints/drive/files/attached-notes.ts +++ b/packages/backend/src/server/api/endpoints/drive/files/attached-notes.ts @@ -1,6 +1,7 @@ import { DriveFiles, Notes } from '@/models/index.js'; import define from '@/server/api/define.js'; import { ApiError } from '@/server/api/error.js'; +import { makePaginationQuery } from '@/server/api/common/make-pagination-query.js'; export const meta = { tags: ['drive', 'notes'], @@ -28,6 +29,9 @@ export const paramDef = { type: 'object', properties: { fileId: { type: 'string', format: 'misskey:id' }, + sinceId: { type: 'string', format: 'misskey:id' }, + untilId: { type: 'string', format: 'misskey:id' }, + limit: { type: 'integer', minimum: 1, maximum: 100, default: 10 }, }, required: ['fileId'], } as const; @@ -42,8 +46,13 @@ export default define(meta, paramDef, async (ps, user) => { if (file == null) throw new ApiError('NO_SUCH_FILE'); - const notes = await Notes.createQueryBuilder('note') - .where(':file = ANY(note.fileIds)', { file: file.id }) + const notes = await makePaginationQuery( + Notes.createQueryBuilder('note'), + ps.sinceId, + ps.untilId, + ) + .andWhere(':file = ANY(note.fileIds)', { file: file.id }) + .take(ps.limit) .getMany(); return await Notes.packMany(notes, user, {