1
0
Fork 0
mirror of https://github.com/Chocobozzz/PeerTube.git synced 2025-10-04 10:19:35 +02:00

Implement user blocking on server side

This commit is contained in:
Chocobozzz 2018-08-08 14:58:21 +02:00
parent 6b09aba90d
commit e69219184b
No known key found for this signature in database
GPG key ID: 583A612D890159BE
15 changed files with 287 additions and 59 deletions

View file

@ -2,7 +2,7 @@ import 'express-validator'
import * as validator from 'validator'
import { UserRole } from '../../../shared'
import { CONSTRAINTS_FIELDS, NSFW_POLICY_TYPES } from '../../initializers'
import { exists, isFileValid } from './misc'
import { exists, isFileValid, isBooleanValid } from './misc'
import { values } from 'lodash'
const USERS_CONSTRAINTS_FIELDS = CONSTRAINTS_FIELDS.USERS
@ -29,17 +29,17 @@ function isUserDescriptionValid (value: string) {
return value === null || (exists(value) && validator.isLength(value, CONSTRAINTS_FIELDS.USERS.DESCRIPTION))
}
function isBoolean (value: any) {
return typeof value === 'boolean' || (typeof value === 'string' && validator.isBoolean(value))
}
const nsfwPolicies = values(NSFW_POLICY_TYPES)
function isUserNSFWPolicyValid (value: any) {
return exists(value) && nsfwPolicies.indexOf(value) !== -1
}
function isUserAutoPlayVideoValid (value: any) {
return isBoolean(value)
return isBooleanValid(value)
}
function isUserBlockedValid (value: any) {
return isBooleanValid(value)
}
function isUserRoleValid (value: any) {
@ -57,6 +57,7 @@ function isAvatarFile (files: { [ fieldname: string ]: Express.Multer.File[] } |
// ---------------------------------------------------------------------------
export {
isUserBlockedValid,
isUserPasswordValid,
isUserRoleValid,
isUserVideoQuotaValid,