Skip to content

Commit

Permalink
fix(server): notes/createで、fileIdsと見つかったファイルの数が異なる場合はエラーにする (#9911)
Browse files Browse the repository at this point in the history
* fix(server): notes/createで、fileIdsと見つかったファイルの数が異なる場合はエラーにする

* NO_SUCH_FILE
  • Loading branch information
tamaina authored Feb 24, 2023
1 parent 5c989ed commit e4336f5
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions packages/backend/src/server/api/endpoints/notes/create.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -207,6 +213,10 @@ export default class extends Endpoint<typeof meta, typeof paramDef> {
.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;
Expand Down

0 comments on commit e4336f5

Please sign in to comment.