mirror of
https://github.com/monkeytypegame/monkeytype.git
synced 2025-12-09 12:56:07 +08:00
increased report limits
This commit is contained in:
parent
d45589354e
commit
ed4f109c56
1 changed files with 8 additions and 4 deletions
|
|
@ -1,7 +1,8 @@
|
|||
const MonkeyError = require("../handlers/error");
|
||||
const { mongoDB } = require("../init/mongodb");
|
||||
|
||||
const MAX_REPORTS = 100;
|
||||
const MAX_REPORTS = 1000;
|
||||
const CONTENT_REPORT_LIMIT = 5;
|
||||
|
||||
class ReportDAO {
|
||||
static async createReport(report) {
|
||||
|
|
@ -14,12 +15,15 @@ class ReportDAO {
|
|||
);
|
||||
}
|
||||
|
||||
const reportAlreadyExists = reports.find((existingReport) => {
|
||||
const reportAlreadyExists = reports.filter((existingReport) => {
|
||||
return existingReport.details.contentId === report.details.contentId;
|
||||
});
|
||||
|
||||
if (reportAlreadyExists) {
|
||||
throw new MonkeyError(409, "A report for this content already exists.");
|
||||
if (reportAlreadyExists.length >= CONTENT_REPORT_LIMIT) {
|
||||
throw new MonkeyError(
|
||||
409,
|
||||
"A report limit for this content has been reached."
|
||||
);
|
||||
}
|
||||
|
||||
await mongoDB().collection("reports").insertOne(report);
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue