diff options
author | Chocobozzz <me@florianbigard.com> | 2019-06-19 14:55:58 +0200 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2019-06-19 15:05:36 +0200 |
commit | 3caf77d3b11f2dbc12e52d665183d36604c1dab9 (patch) | |
tree | 53e08727d5f1dc8be2bd4f4a14dadc05f607a9fb /server/helpers/custom-validators/users.ts | |
parent | bbe078ba55be635b5fc92f8f6286c45792b9e7e5 (diff) | |
download | PeerTube-3caf77d3b11f2dbc12e52d665183d36604c1dab9.tar.gz PeerTube-3caf77d3b11f2dbc12e52d665183d36604c1dab9.tar.zst PeerTube-3caf77d3b11f2dbc12e52d665183d36604c1dab9.zip |
Add language filters in user preferences
Diffstat (limited to 'server/helpers/custom-validators/users.ts')
-rw-r--r-- | server/helpers/custom-validators/users.ts | 7 |
1 files changed, 6 insertions, 1 deletions
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' | |||
2 | import * as validator from 'validator' | 2 | import * as validator from 'validator' |
3 | import { UserRole } from '../../../shared' | 3 | import { UserRole } from '../../../shared' |
4 | import { CONSTRAINTS_FIELDS, NSFW_POLICY_TYPES } from '../../initializers/constants' | 4 | import { CONSTRAINTS_FIELDS, NSFW_POLICY_TYPES } from '../../initializers/constants' |
5 | import { exists, isBooleanValid, isFileValid } from './misc' | 5 | import { exists, isArray, isBooleanValid, isFileValid } from './misc' |
6 | import { values } from 'lodash' | 6 | import { values } from 'lodash' |
7 | 7 | ||
8 | const USERS_CONSTRAINTS_FIELDS = CONSTRAINTS_FIELDS.USERS | 8 | const USERS_CONSTRAINTS_FIELDS = CONSTRAINTS_FIELDS.USERS |
@@ -54,6 +54,10 @@ function isUserAutoPlayVideoValid (value: any) { | |||
54 | return isBooleanValid(value) | 54 | return isBooleanValid(value) |
55 | } | 55 | } |
56 | 56 | ||
57 | function isUserVideoLanguages (value: any) { | ||
58 | return value === null || (isArray(value) && value.length < CONSTRAINTS_FIELDS.USERS.VIDEO_LANGUAGES.max) | ||
59 | } | ||
60 | |||
57 | function isUserAdminFlagsValid (value: any) { | 61 | function isUserAdminFlagsValid (value: any) { |
58 | return exists(value) && validator.isInt('' + value) | 62 | return exists(value) && validator.isInt('' + value) |
59 | } | 63 | } |
@@ -84,6 +88,7 @@ export { | |||
84 | isUserVideosHistoryEnabledValid, | 88 | isUserVideosHistoryEnabledValid, |
85 | isUserBlockedValid, | 89 | isUserBlockedValid, |
86 | isUserPasswordValid, | 90 | isUserPasswordValid, |
91 | isUserVideoLanguages, | ||
87 | isUserBlockedReasonValid, | 92 | isUserBlockedReasonValid, |
88 | isUserRoleValid, | 93 | isUserRoleValid, |
89 | isUserVideoQuotaValid, | 94 | isUserVideoQuotaValid, |