From 3caf77d3b11f2dbc12e52d665183d36604c1dab9 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Wed, 19 Jun 2019 14:55:58 +0200 Subject: Add language filters in user preferences --- server/helpers/custom-validators/users.ts | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'server/helpers') diff --git a/server/helpers/custom-validators/users.ts b/server/helpers/custom-validators/users.ts index 56bc10b16..738d5cbbf 100644 --- a/server/helpers/custom-validators/users.ts +++ b/server/helpers/custom-validators/users.ts @@ -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, -- cgit v1.2.3