From 7a9eb30cefeef6ef5d7f5dd9c1736343d74b071a Mon Sep 17 00:00:00 2001 From: Miodec Date: Thu, 29 Jun 2023 14:00:33 +0200 Subject: [PATCH] added content limit for tags --- backend/src/api/controllers/user.ts | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/backend/src/api/controllers/user.ts b/backend/src/api/controllers/user.ts index 365989eba..e8ee7205c 100644 --- a/backend/src/api/controllers/user.ts +++ b/backend/src/api/controllers/user.ts @@ -498,6 +498,16 @@ export async function addTag( const { uid } = req.ctx.decodedToken; const { tagName } = req.body; + const user = await UserDAL.getUser(uid, "add tag"); + + if (!user) { + throw new MonkeyError(404, "User not found"); + } + + if ((user?.tags?.length ?? 0) >= 10) { + throw new MonkeyError(400, "You can only have up to 10 tags"); + } + const tag = await UserDAL.addTag(uid, tagName); return new MonkeyResponse("Tag updated", tag); }