forked from FoundKeyGang/FoundKey
server: error when trying to unclip note that is not clipped
When a note is not added to a clip and an API call tries to remove the note from that clip, the API will now raise an error. Changelog: Changed
This commit is contained in:
parent
4c5aa9e538
commit
ee70ad52fc
1 changed files with 12 additions and 1 deletions
|
@ -22,6 +22,13 @@ export const meta = {
|
||||||
code: 'NO_SUCH_NOTE',
|
code: 'NO_SUCH_NOTE',
|
||||||
id: 'aff017de-190e-434b-893e-33a9ff5049d8',
|
id: 'aff017de-190e-434b-893e-33a9ff5049d8',
|
||||||
},
|
},
|
||||||
|
|
||||||
|
notClipped: {
|
||||||
|
message: 'That note is not added to this clip.',
|
||||||
|
code: 'NOT_CLIPPED',
|
||||||
|
id: '6b20c697-6e51-4120-b340-0e47899c7a20',
|
||||||
|
httpStatusCode: 409,
|
||||||
|
},
|
||||||
},
|
},
|
||||||
} as const;
|
} as const;
|
||||||
|
|
||||||
|
@ -50,8 +57,12 @@ export default define(meta, paramDef, async (ps, user) => {
|
||||||
throw e;
|
throw e;
|
||||||
});
|
});
|
||||||
|
|
||||||
await ClipNotes.delete({
|
const { affected } = await ClipNotes.delete({
|
||||||
noteId: note.id,
|
noteId: note.id,
|
||||||
clipId: clip.id,
|
clipId: clip.id,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
if (affected == 0) {
|
||||||
|
throw new ApiError(meta.errors.notClipped);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in a new issue