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:
Johann150 2022-10-19 21:54:37 +02:00
parent 4c5aa9e538
commit ee70ad52fc
Signed by untrusted user: Johann150
GPG key ID: 9EE6577A2A06F8F1

View file

@ -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);
}
}); });