mirror of
https://github.com/monkeytypegame/monkeytype.git
synced 2025-03-04 02:34:43 +08:00
impr(reporting): dont allow users to report the same content multiple times
closes #5288 !nuf
This commit is contained in:
parent
163a0302e4
commit
4607297c95
1 changed files with 8 additions and 0 deletions
|
@ -35,5 +35,13 @@ export async function createReport(
|
|||
);
|
||||
}
|
||||
|
||||
const countFromUserMakingReport = sameReports.filter((r) => {
|
||||
return r.uid === report.uid;
|
||||
}).length;
|
||||
|
||||
if (countFromUserMakingReport > 0) {
|
||||
throw new MonkeyError(409, "You have already reported this content.");
|
||||
}
|
||||
|
||||
await db.collection<MonkeyTypes.Report>(COLLECTION_NAME).insertOne(report);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue