only allowing 100 submissions per language

This commit is contained in:
Miodec 2023-07-25 17:00:29 +02:00
parent 99111ec3e8
commit 59c34fc988

View file

@ -42,6 +42,17 @@ export async function add(
throw new MonkeyError(500, `Invalid language name`, language);
}
const count = await db
.collection("new-quotes")
.countDocuments({ language: language });
if (count >= 100) {
throw new MonkeyError(
409,
"There are already 100 quotes in the queue for this language."
);
}
//check for duplicate first
const fileDir = path.join(
__dirname,