mirror of
https://github.com/monkeytypegame/monkeytype.git
synced 2025-09-18 12:38:42 +08:00
moved content limit check to the DAL
This commit is contained in:
parent
7a9eb30cef
commit
08a96e634a
2 changed files with 6 additions and 10 deletions
|
@ -498,16 +498,6 @@ 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);
|
||||
}
|
||||
|
|
|
@ -272,6 +272,12 @@ export async function addTag(
|
|||
uid: string,
|
||||
name: string
|
||||
): Promise<MonkeyTypes.UserTag> {
|
||||
const user = await getUser(uid, "add tag");
|
||||
|
||||
if ((user?.tags?.length ?? 0) >= 10) {
|
||||
throw new MonkeyError(400, "You can only have up to 10 tags");
|
||||
}
|
||||
|
||||
const _id = new ObjectId();
|
||||
const toPush = {
|
||||
_id,
|
||||
|
|
Loading…
Add table
Reference in a new issue