diff --git a/packages/backend/src/core/ClipService.ts b/packages/backend/src/core/ClipService.ts index 5dfb3b33a..3d9982e80 100644 --- a/packages/backend/src/core/ClipService.ts +++ b/packages/backend/src/core/ClipService.ts @@ -143,6 +143,12 @@ export class ClipService { throw new ClipService.NoSuchClipError(); } + const note = await this.notesRepository.findOneBy({ id: noteId }); + + if (note == null) { + throw new ClipService.NoSuchNoteError(); + } + await this.clipNotesRepository.delete({ noteId: noteId, clipId: clip.id, diff --git a/packages/backend/src/server/api/endpoints/clips/remove-note.ts b/packages/backend/src/server/api/endpoints/clips/remove-note.ts index d84a57cac..7b153cb55 100644 --- a/packages/backend/src/server/api/endpoints/clips/remove-note.ts +++ b/packages/backend/src/server/api/endpoints/clips/remove-note.ts @@ -52,6 +52,8 @@ export default class extends Endpoint { // eslint- } catch (e) { if (e instanceof ClipService.NoSuchClipError) { throw new ApiError(meta.errors.noSuchClip); + } else if (e instanceof ClipService.NoSuchNoteError) { + throw new ApiError(meta.errors.noSuchNote); } throw e; }