From 734e4237817a021d2380729fe91b6cc45e0941eb Mon Sep 17 00:00:00 2001 From: Andrea Vos Date: Mon, 26 Jul 2021 17:04:39 +0200 Subject: [PATCH] [abuse] don't generate duplicate automated abuse reports --- server/routes/profile.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/server/routes/profile.js b/server/routes/profile.js index fb01ea94e..82f7af6ab 100644 --- a/server/routes/profile.js +++ b/server/routes/profile.js @@ -89,8 +89,8 @@ function* isSuspicious(profile) { } } -const hasAutomatedHandledReports = async (db, id) => { - return (await db.get(SQL`SELECT COUNT(*) AS c FROM reports WHERE userId = ${id} AND isAutomatic = 1 AND isHandled = 1`)).c > 0; +const hasAutomatedReports = async (db, id) => { + return (await db.get(SQL`SELECT COUNT(*) AS c FROM reports WHERE userId = ${id} AND isAutomatic = 1`)).c > 0; } const router = Router(); @@ -162,7 +162,7 @@ router.post('/profile/save', handleErrorAsync(async (req, res) => { } const sus = [...isSuspicious(req.body)]; - if (sus.length && !await hasAutomatedHandledReports(req.db, req.user.id)) { + if (sus.length && !await hasAutomatedReports(req.db, req.user.id)) { await req.db.get(SQL` INSERT INTO reports (id, userId, reporterId, isAutomatic, comment, isHandled) VALUES (${ulid()}, ${req.user.id}, null, 1, ${sus.join(', ')}, 0);