impr(reporting): dont allow users to report the same content multiple times

closes #5288
!nuf
This commit is contained in:
Miodec 2024-04-08 12:56:58 +02:00
parent 163a0302e4
commit 4607297c95

View file

@ -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);
}