From 59c34fc9883d6f0c0b9ce7ed5a838922c83bda12 Mon Sep 17 00:00:00 2001 From: Miodec Date: Tue, 25 Jul 2023 17:00:29 +0200 Subject: [PATCH] only allowing 100 submissions per language --- backend/src/dal/new-quotes.ts | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/backend/src/dal/new-quotes.ts b/backend/src/dal/new-quotes.ts index bbc28a71c..95e061a31 100644 --- a/backend/src/dal/new-quotes.ts +++ b/backend/src/dal/new-quotes.ts @@ -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,