mirror of
https://github.com/monkeytypegame/monkeytype.git
synced 2025-02-28 08:43:07 +08:00
added content limit for tags
This commit is contained in:
parent
ca38437153
commit
7a9eb30cef
1 changed files with 10 additions and 0 deletions
|
@ -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);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue