1
0
Fork 0
mirror of https://github.com/Chocobozzz/PeerTube.git synced 2025-10-03 09:49:20 +02:00

Add language filters in user preferences

This commit is contained in:
Chocobozzz 2019-06-19 14:55:58 +02:00
parent bbe078ba55
commit 3caf77d3b1
No known key found for this signature in database
GPG key ID: 583A612D890159BE
24 changed files with 443 additions and 150 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/constants'
import { exists, isBooleanValid, isFileValid } from './misc'
import { exists, isArray, isBooleanValid, isFileValid } from './misc'
import { values } from 'lodash'
const USERS_CONSTRAINTS_FIELDS = CONSTRAINTS_FIELDS.USERS
@ -54,6 +54,10 @@ function isUserAutoPlayVideoValid (value: any) {
return isBooleanValid(value)
}
function isUserVideoLanguages (value: any) {
return value === null || (isArray(value) && value.length < CONSTRAINTS_FIELDS.USERS.VIDEO_LANGUAGES.max)
}
function isUserAdminFlagsValid (value: any) {
return exists(value) && validator.isInt('' + value)
}
@ -84,6 +88,7 @@ export {
isUserVideosHistoryEnabledValid,
isUserBlockedValid,
isUserPasswordValid,
isUserVideoLanguages,
isUserBlockedReasonValid,
isUserRoleValid,
isUserVideoQuotaValid,