Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(server): notes/createで、fileIdsと見つかったファイルの数が異なる場合はエラーにする #9911

Merged
merged 3 commits into from
Feb 24, 2023
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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',
},

fileNotFound: {
message: 'Some files are not found.',
code: 'FILE_NOT_FOUND',
tamaina marked this conversation as resolved.
Show resolved Hide resolved
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.fileNotFound);
}
}

let renote: Note | null = null;
Expand Down