mirror of
https://gitlab.com/PronounsPage/PronounsPage.git
synced 2025-09-22 20:24:18 -04:00
[neutratywy] anti-troll measures
This commit is contained in:
parent
5e0522d6d0
commit
ab2865493a
@ -1,7 +1,7 @@
|
||||
<template>
|
||||
<div>
|
||||
<div v-for="(synonym, i) in val" :key="i" class="input-group input-group-sm p-1">
|
||||
<input type="text" class="form-control" v-model="val[i]" required ref="inp">
|
||||
<input type="text" class="form-control" v-model="val[i]" required ref="inp" maxlength="24">
|
||||
<div v-if="i" class="input-group-append">
|
||||
<button type="button" class="btn btn-outline-danger btn-sm" @click="remove(i)">
|
||||
<Icon v="times"/>
|
||||
|
@ -45,6 +45,24 @@ const remove = async (db, id) => {
|
||||
`);
|
||||
}
|
||||
|
||||
const trollWords = [
|
||||
'cipeusz',
|
||||
'feminazi',
|
||||
'bruksela',
|
||||
'zboczeń',
|
||||
];
|
||||
|
||||
const isTroll = (body) => {
|
||||
const jsonBody = JSON.stringify(body);
|
||||
for (let trollWord of trollWords) {
|
||||
if (jsonBody.indexOf(trollWord) > -1) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
export default async function (req, res, next) {
|
||||
const db = await sqlite.open({
|
||||
filename: __dirname + '/../data/db.sqlite',
|
||||
@ -64,18 +82,20 @@ export default async function (req, res, next) {
|
||||
ORDER BY approved, masc
|
||||
`);
|
||||
} else if (req.method === 'POST' && url === '/submit') {
|
||||
const id = ulid()
|
||||
await db.get(SQL`
|
||||
INSERT INTO nouns (id, masc, fem, neutr, mascPl, femPl, neutrPl, approved, base_id)
|
||||
VALUES (
|
||||
${id},
|
||||
${req.body.data.masc.join('|')}, ${req.body.data.fem.join('|')}, ${req.body.data.neutr.join('|')},
|
||||
${req.body.data.mascPl.join('|')}, ${req.body.data.femPl.join('|')}, ${req.body.data.neutrPl.join('|')},
|
||||
0, ${req.body.data.base}
|
||||
)
|
||||
`);
|
||||
if (isAdmin) {
|
||||
await approve(db, id);
|
||||
if (isAdmin || !isTroll(req.body.data)) {
|
||||
const id = ulid()
|
||||
await db.get(SQL`
|
||||
INSERT INTO nouns (id, masc, fem, neutr, mascPl, femPl, neutrPl, approved, base_id)
|
||||
VALUES (
|
||||
${id},
|
||||
${req.body.data.masc.join('|')}, ${req.body.data.fem.join('|')}, ${req.body.data.neutr.join('|')},
|
||||
${req.body.data.mascPl.join('|')}, ${req.body.data.femPl.join('|')}, ${req.body.data.neutrPl.join('|')},
|
||||
0, ${req.body.data.base}
|
||||
)
|
||||
`);
|
||||
if (isAdmin) {
|
||||
await approve(db, id);
|
||||
}
|
||||
}
|
||||
result = 'ok';
|
||||
} else if (req.method === 'POST' && url.startsWith('/approve/') && isAdmin) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user