#245 require ban reason

This commit is contained in:
Avris 2021-08-12 12:14:34 +02:00
parent 4abddf3c64
commit bfca7fdc2a
18 changed files with 95 additions and 16 deletions

View File

@ -23,6 +23,17 @@
</a> </a>
<div v-else> <div v-else>
<textarea v-model="user.bannedReason" class="form-control" rows="3" :placeholder="$t('ban.reason') + ' ' + $t('ban.visible')" :disabled="saving"></textarea> <textarea v-model="user.bannedReason" class="form-control" rows="3" :placeholder="$t('ban.reason') + ' ' + $t('ban.visible')" :disabled="saving"></textarea>
<div class="form-group">
<p class="my-1"><label><strong><T>ban.terms</T>:</strong></label></p>
<div style="columns: 3" class="small">
<div class="form-check ps-0" v-for="term in forbidden">
<label>
<input type="checkbox" :value="term" v-model="user.bannedTerms"/>
{{ term }}
</label>
</div>
</div>
</div>
<button class="btn btn-danger d-block w-100 mt-2" :disabled="saving" @click="ban"> <button class="btn btn-danger d-block w-100 mt-2" :disabled="saving" @click="ban">
<Icon v="ban"/> <Icon v="ban"/>
<T>ban.action</T> <T>ban.action</T>
@ -34,6 +45,7 @@
<script> <script>
import ClientOnly from 'vue-client-only' import ClientOnly from 'vue-client-only'
import forbidden from "../src/forbidden";
export default { export default {
components: { ClientOnly }, components: { ClientOnly },
@ -49,6 +61,8 @@
showBanForm: !!this.user.bannedReason, showBanForm: !!this.user.bannedReason,
saving: false, saving: false,
forbidden,
} }
}, },
methods: { methods: {
@ -58,6 +72,7 @@
try { try {
await this.$post(`/admin/ban/${encodeURIComponent(this.user.username)}`, { await this.$post(`/admin/ban/${encodeURIComponent(this.user.username)}`, {
reason: this.user.bannedReason, reason: this.user.bannedReason,
terms: this.user.bannedTerms,
}); });
window.location.reload(); window.location.reload();
} finally { } finally {

View File

@ -91,9 +91,7 @@
<blockquote class="small"> <blockquote class="small">
It is forbidden to post on the Service any Content that might break the law or violate social norms, It is forbidden to post on the Service any Content that might break the law or violate social norms,
including but not limited to: including but not limited to:
propagation of totalitarian regimes, hate speech, racism, xenophobia, homophobia, transphobia, queerphobia, <template v-for="(term, i) in forbidden"><span :class="[$user().bannedTerms.includes(term) ? 'fw-bold' : '']">{{term}}</span><template v-if="i !== forbidden.length - 1">, </template></template>.
misogyny, harassment, impersonation, child pornography, unlawful conduct, misinformation,
sharing of someone else's personal data, spam, advertisement, copyright or trademark violations.
</blockquote> </blockquote>
</div> </div>
</div> </div>
@ -112,6 +110,7 @@
<script> <script>
import { mapState } from 'vuex' import { mapState } from 'vuex'
import {DateTime} from "luxon"; import {DateTime} from "luxon";
import forbidden from "../src/forbidden";
export default { export default {
data() { data() {
@ -119,6 +118,7 @@
hamburgerActive: false, hamburgerActive: false,
hamburgerShown: false, hamburgerShown: false,
censusDismissed: false, censusDismissed: false,
forbidden,
}; };
}, },
computed: { computed: {

View File

@ -537,6 +537,7 @@ mode:
ban: ban:
reason: 'Grund der Sperrung' reason: 'Grund der Sperrung'
visible: '(dies wird der*m Nutzer*in sichtbar sein)' visible: '(dies wird der*m Nutzer*in sichtbar sein)'
terms: 'Terms rules broken (required)' # TODO
action: 'Diese Person sperren' action: 'Diese Person sperren'
confirm: 'Bist du sicher, die Person @%username% zu sperren?' confirm: 'Bist du sicher, die Person @%username% zu sperren?'
header: 'Du wurdest gesperrt. Dein Profil kann nicht mehr angesehen werden.' header: 'Du wurdest gesperrt. Dein Profil kann nicht mehr angesehen werden.'

View File

@ -622,6 +622,7 @@ mode:
ban: ban:
reason: 'Ban reason' reason: 'Ban reason'
visible: '(this will be visible to the user)' visible: '(this will be visible to the user)'
terms: 'Terms rules broken (required)'
action: 'Ban this person' action: 'Ban this person'
confirm: 'Are you sure you want to ban @%username%?' confirm: 'Are you sure you want to ban @%username%?'
header: 'You''re banned. Your profile will not be shown to anyone.' header: 'You''re banned. Your profile will not be shown to anyone.'

View File

@ -40,7 +40,7 @@ home:
alt: 'También puedes introducir formas intercambiables por separado en cada campo, p. ej. <code>el&ella</code> = „el” o „ella”.' alt: 'También puedes introducir formas intercambiables por separado en cada campo, p. ej. <code>el&ella</code> = „el” o „ella”.'
pronunciation: 'También puedes especificar la pronunciación de una entrada usando el AFI, p. ej. <code>ellx|ˈe.ʝe</code> = „ellx”, se pronuncia /ˈe.ʝe/.' pronunciation: 'También puedes especificar la pronunciación de una entrada usando el AFI, p. ej. <code>ellx|ˈe.ʝe</code> = „ellx”, se pronuncia /ˈe.ʝe/.'
whatisit: '¿Por qué importan los pronombres?' whatisit: '¿Por qué importan los pronombres?'
mission: mission:
header: 'Nuestra misión' header: 'Nuestra misión'
summary: 'Luchamos por la libertad, el respeto y la inclusividad en la lengua.' summary: 'Luchamos por la libertad, el respeto y la inclusividad en la lengua.'
@ -549,6 +549,7 @@ mode:
ban: ban:
reason: 'Razón para banear' reason: 'Razón para banear'
visible: '(esto será visible para le usuario)' visible: '(esto será visible para le usuario)'
terms: 'Terms rules broken (required)' # TODO
action: 'Banear esta persona' action: 'Banear esta persona'
confirm: '¿Estás segure que quieres banear a @%username%?' confirm: '¿Estás segure que quieres banear a @%username%?'
header: 'Has sido baneado. Tu perfil no se mostrará a nadie.' header: 'Has sido baneado. Tu perfil no se mostrará a nadie.'

View File

@ -542,6 +542,7 @@ mode:
ban: ban:
reason: 'Raison du bannissement' reason: 'Raison du bannissement'
visible: '(visible par lutilisateur)' visible: '(visible par lutilisateur)'
terms: 'Terms rules broken (required)' # TODO
action: 'Bannir lutilisateur' action: 'Bannir lutilisateur'
confirm: 'Voulez-vous bannir @%username%?' confirm: 'Voulez-vous bannir @%username%?'
header: 'Vous êtes banni. Votre profil napparaîtra plus aux autres utilisateurs.' header: 'Vous êtes banni. Votre profil napparaîtra plus aux autres utilisateurs.'

View File

@ -534,6 +534,7 @@ mode:
ban: ban:
reason: 'Ban reason' reason: 'Ban reason'
visible: '(this will be visible to the user)' visible: '(this will be visible to the user)'
terms: 'Terms rules broken (required)' # TODO
action: 'Ban this person' action: 'Ban this person'
confirm: 'Are you sure you want to ban @%username%?' confirm: 'Are you sure you want to ban @%username%?'
header: 'You''re banned. Your profile will not be shown to anyone.' header: 'You''re banned. Your profile will not be shown to anyone.'

View File

@ -23,8 +23,8 @@ home:
Du ville vel ikke kalt Anne “Ingrid” bare fordi du liker det navnet bedre Du ville vel ikke kalt Anne “Ingrid” bare fordi du liker det navnet bedre
eller fordi du synes “hun ser ut som en Ingrid”? eller fordi du synes “hun ser ut som en Ingrid”?
Selv dersom hun har navnet “Ingrid” i fødselsattesten hennes Selv dersom hun har navnet “Ingrid” i fødselsattesten hennes
men hun hater det, og foretrekker å bruke “Anne” men hun hater det, og foretrekker å bruke “Anne”
så ville du kalt henne Anne. Det er likedan med pronomen. så ville du kalt henne Anne. Det er likedan med pronomen.
Hvis du ikke vil være frekk mot noen, kall de som de vil bli kalt.. Hvis du ikke vil være frekk mot noen, kall de som de vil bli kalt..
Den eneste forskjellen er at vi vanligvis vet navnet til en person, men ikke pronomen Den eneste forskjellen er at vi vanligvis vet navnet til en person, men ikke pronomen
Vi introduserer oss selv med ett navn, men ikke med pronomen. La oss endre det! Vi introduserer oss selv med ett navn, men ikke med pronomen. La oss endre det!
@ -52,7 +52,7 @@ home:
slik at <em>andres</em> pronomen er respektert. slik at <em>andres</em> pronomen er respektert.
inclusiveness: > inclusiveness: >
<strong>Inklusivitet</strong> <strong>Inklusivitet</strong>
slik at når vi snakker om personer vi ikke kjenner, slik at når vi snakker om personer vi ikke kjenner,
antar vi ikke kjønnet deres, og ekskluderer dem ikke. antar vi ikke kjønnet deres, og ekskluderer dem ikke.
pronouns: pronouns:
@ -201,7 +201,7 @@ faq:
{https://gender.wikia.org/wiki/Two-Spirit=(to åndelig)}, etc. etc. {https://gender.wikia.org/wiki/Two-Spirit=(to åndelig)}, etc. etc.
- > - >
Intetkjønn eller ikke-binær er et begrep som beskriver identiteten til Intetkjønn eller ikke-binær er et begrep som beskriver identiteten til
de som ikke passer inn i de binære mann/kvinne-båsene. de som ikke passer inn i de binære mann/kvinne-båsene.
Det inkluderer folk som er Det inkluderer folk som er
{https://gender.wikia.org/wiki/Agender=akjønnet}, {https://gender.wikia.org/wiki/Agender=akjønnet},
{https://gender.wikia.org/wiki/Gender_Fluid=kjønnsflytende}, {https://gender.wikia.org/wiki/Gender_Fluid=kjønnsflytende},
@ -541,6 +541,7 @@ mode:
ban: ban:
reason: 'Grunn til forbud' reason: 'Grunn til forbud'
visible: '(dette vil kunne bli sett av brukeren)' visible: '(dette vil kunne bli sett av brukeren)'
terms: 'Terms rules broken (required)' # TODO
action: 'Forby denne personen' action: 'Forby denne personen'
confirm: 'Er du sikker på at du vil forby @%username%?' confirm: 'Er du sikker på at du vil forby @%username%?'
header: 'Du er forbydd. Profilen din vil ikke bli vist til noen.' header: 'Du er forbydd. Profilen din vil ikke bli vist til noen.'

View File

@ -1160,6 +1160,7 @@ mode:
ban: ban:
reason: 'Powód blokady' reason: 'Powód blokady'
visible: '(to będzie widoczne dla osoby zbanowanej)' visible: '(to będzie widoczne dla osoby zbanowanej)'
terms: 'Złamane punkty regulaminu (wymagane)'
action: 'Zablokuj tę osobę' action: 'Zablokuj tę osobę'
confirm: 'Czy na pewno chcesz zbanować @%username%?' confirm: 'Czy na pewno chcesz zbanować @%username%?'
header: 'Twoje konto jest zablokowane. Twoje profile nie są widoczne publicznie.' header: 'Twoje konto jest zablokowane. Twoje profile nie są widoczne publicznie.'

View File

@ -548,6 +548,7 @@ mode:
ban: ban:
reason: 'Razão de ban' reason: 'Razão de ban'
visible: '(isso vai ser visto para usuárie)' visible: '(isso vai ser visto para usuárie)'
terms: 'Terms rules broken (required)' # TODO
action: 'Ban essa pessoa' action: 'Ban essa pessoa'
confirm: 'Você está certe que quer banir @%username%?' confirm: 'Você está certe que quer banir @%username%?'
header: 'Você está banido. Seu perfil não mais aparecerá em nosso site.' header: 'Você está banido. Seu perfil não mais aparecerá em nosso site.'

View File

@ -1108,6 +1108,7 @@ mode:
ban: ban:
reason: 'Ban reason' reason: 'Ban reason'
visible: '(this will be visible to the user)' visible: '(this will be visible to the user)'
terms: 'Terms rules broken (required)' # TODO
action: 'Ban this person' action: 'Ban this person'
confirm: 'Are you sure you want to ban @%username%?' confirm: 'Are you sure you want to ban @%username%?'
header: 'You''re banned. Your profile will not be shown to anyone.' header: 'You''re banned. Your profile will not be shown to anyone.'

View File

@ -552,6 +552,7 @@ mode:
ban: ban:
reason: 'Ban reason' reason: 'Ban reason'
visible: '(this will be visible to the user)' visible: '(this will be visible to the user)'
terms: 'Terms rules broken (required)' # TODO
action: 'Ban this person' action: 'Ban this person'
confirm: 'Are you sure you want to ban @%username%?' confirm: 'Are you sure you want to ban @%username%?'
header: 'You''re banned. Your profile will not be shown to anyone.' header: 'You''re banned. Your profile will not be shown to anyone.'

View File

@ -518,6 +518,7 @@ mode:
ban: ban:
reason: '封禁原因' reason: '封禁原因'
visible: '(用戶可以看見這個)' visible: '(用戶可以看見這個)'
terms: 'Terms rules broken (required)' # TODO
action: '封禁用戶' action: '封禁用戶'
confirm: '您確定要封禁@%username%嗎' confirm: '您確定要封禁@%username%嗎'
header: '您被封禁了。你的資料不會對任何人顯示。' header: '您被封禁了。你的資料不會對任何人顯示。'

View File

@ -0,0 +1,7 @@
-- Up
ALTER TABLE users ADD COLUMN bannedTerms TEXT NULL DEFAULT NULL;
ALTER TABLE users ADD COLUMN bannedBy TEXT NULL DEFAULT NULL;
-- Down

View File

@ -47,9 +47,8 @@
<p> <p>
It is forbidden to post on the Service any Content that might break the law or violate social norms, It is forbidden to post on the Service any Content that might break the law or violate social norms,
including but not limited to: propagation of totalitarian regimes, hate speech, racism, xenophobia, including but not limited to:
homophobia, transphobia, queerphobia, misogyny, harassment, impersonation, child pornography, unlawful conduct, misinformation, {{ forbidden.join(', ') }}.
sharing of someone else's personal data, spam, advertisement, copyright or trademark violations.
</p> </p>
<p> <p>
@ -100,3 +99,15 @@
</p> </p>
</div> </div>
</template> </template>
<script>
import forbidden from "../src/forbidden";
export default {
data() {
return {
forbidden,
};
}
}
</script>

View File

@ -133,11 +133,24 @@ router.post('/admin/ban/:username', handleErrorAsync(async (req, res) => {
return res.status(400).json({error: 'No such user'}); return res.status(400).json({error: 'No such user'});
} }
await req.db.get(SQL` if (req.body.reason) {
UPDATE users if (!req.body.terms.length) {
SET bannedReason = ${req.body.reason || null} return res.status(400).json({error: 'Terms are required'});
WHERE id = ${user.id} }
`); await req.db.get(SQL`
UPDATE users
SET bannedReason = ${req.body.reason},
bannedTerms = ${req.body.terms.join(',')},
bannedBy = ${req.user.id}
WHERE id = ${user.id}
`);
} else {
await req.db.get(SQL`
UPDATE users
SET bannedReason = null
WHERE id = ${user.id}
`);
}
await req.db.get(SQL` await req.db.get(SQL`
UPDATE reports UPDATE reports

View File

@ -115,6 +115,7 @@ router.get('/profile/get/:username', handleErrorAsync(async (req, res) => {
users.email, users.email,
users.avatarSource, users.avatarSource,
users.bannedReason, users.bannedReason,
users.bannedTerms,
users.roles != '' AS team users.roles != '' AS team
FROM users FROM users
WHERE users.usernameNorm = ${normalise(req.params.username)} WHERE users.usernameNorm = ${normalise(req.params.username)}
@ -130,6 +131,8 @@ router.get('/profile/get/:username', handleErrorAsync(async (req, res) => {
delete user.email; delete user.email;
user.avatar = await avatar(req.db, user); user.avatar = await avatar(req.db, user);
user.bannedTerms = user.bannedTerms ? user.bannedTerms.split(',') : [];
return res.json({ return res.json({
...user, ...user,
profiles: await fetchProfiles(req.db, req.params.username, isSelf), profiles: await fetchProfiles(req.db, req.params.username, isSelf),

19
src/forbidden.js Normal file
View File

@ -0,0 +1,19 @@
export default [
'propagation of totalitarian regimes',
'hate speech',
'racism',
'xenophobia',
'homophobia',
'transphobia',
'queerphobia',
'misogyny',
'harassment',
'impersonation',
'child pornography',
'unlawful conduct',
'misinformation',
'sharing of someone else\'s personal data',
'spam',
'advertisement',
'copyright or trademark violations',
];