From a43c7c0ff611af8d1299973a85605a3d6ca1c6a0 Mon Sep 17 00:00:00 2001 From: Andrea Vos Date: Mon, 26 Jun 2023 08:43:11 +0200 Subject: [PATCH] =?UTF-8?q?(admin)=20faster=20profile=20moderation=20?= =?UTF-8?q?=E2=80=93=20introduce=20"mild=20sus"?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit keywords with a lot of false positives should only trigger when accompanied by at least one other keyword --- server/routes/profile.js | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/server/routes/profile.js b/server/routes/profile.js index 38a895f60..f08626419 100644 --- a/server/routes/profile.js +++ b/server/routes/profile.js @@ -302,6 +302,14 @@ function* isSuspicious(profile) { } } +const mildSus = [ + 'fag', + 'faggot', + 'tranny', + 'phobic', + 'kys', +] + const hasAutomatedReports = async (db, id) => { return (await db.get(SQL`SELECT COUNT(*) AS c FROM reports WHERE userId = ${id} AND isAutomatic = 1`)).c > 0; } @@ -696,7 +704,11 @@ router.post('/profile/save', handleErrorAsync(async (req, res) => { await req.db.get(SQL`INSERT INTO links (url) VALUES (${url}) ON CONFLICT (url) DO UPDATE SET expiresAt = null`); } - const sus = [...isSuspicious(req.body)]; + let sus = [...isSuspicious(req.body)]; + // keywords with a lot of false positives should only trigger when accompanied by at least one other keyword + if (sus.length === 1 && mildSus.filter(k => sus[0].startsWith(k + ' (')).length > 0) { + sus = []; + } if (sus.length && !await hasAutomatedReports(req.db, req.user.id)) { await req.db.get(SQL` INSERT INTO reports (id, userId, reporterId, isAutomatic, comment, isHandled, snapshot)