From e4336f5b7657e2f5c40c7e7c71232a6653738574 Mon Sep 17 00:00:00 2001 From: tamaina Date: Fri, 24 Feb 2023 16:32:01 +0900 Subject: [PATCH] =?UTF-8?q?fix(server):=20notes/create=E3=81=A7=E3=80=81fi?= =?UTF-8?q?leIds=E3=81=A8=E8=A6=8B=E3=81=A4=E3=81=8B=E3=81=A3=E3=81=9F?= =?UTF-8?q?=E3=83=95=E3=82=A1=E3=82=A4=E3=83=AB=E3=81=AE=E6=95=B0=E3=81=8C?= =?UTF-8?q?=E7=95=B0=E3=81=AA=E3=82=8B=E5=A0=B4=E5=90=88=E3=81=AF=E3=82=A8?= =?UTF-8?q?=E3=83=A9=E3=83=BC=E3=81=AB=E3=81=99=E3=82=8B=20(#9911)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * fix(server): notes/createで、fileIdsと見つかったファイルの数が異なる場合はエラーにする * NO_SUCH_FILE --- .../backend/src/server/api/endpoints/notes/create.ts | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/packages/backend/src/server/api/endpoints/notes/create.ts b/packages/backend/src/server/api/endpoints/notes/create.ts index 593444968e..f4c5a84a4f 100644 --- a/packages/backend/src/server/api/endpoints/notes/create.ts +++ b/packages/backend/src/server/api/endpoints/notes/create.ts @@ -79,6 +79,12 @@ export const meta = { code: 'YOU_HAVE_BEEN_BLOCKED', id: 'b390d7e1-8a5e-46ed-b625-06271cafd3d3', }, + + noSuchFile: { + message: 'Some files are not found.', + code: 'NO_SUCH_FILE', + id: 'b6992544-63e7-67f0-fa7f-32444b1b5306', + }, }, } as const; @@ -207,6 +213,10 @@ export default class extends Endpoint { .orderBy('array_position(ARRAY[:...fileIds], "id"::text)') .setParameters({ fileIds }) .getMany(); + + if (files.length !== fileIds.length) { + throw new ApiError(meta.errors.noSuchFile); + } } let renote: Note | null = null;