(admin) faster profile moderation – introduce "mild sus"

keywords with a lot of false positives should only trigger when accompanied by at least one other keyword
This commit is contained in:
Andrea Vos 2023-06-26 08:43:11 +02:00
parent 8b024a917c
commit a43c7c0ff6

View File

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