aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/helpers/custom-validators/users.ts
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2018-04-19 11:01:34 +0200
committerChocobozzz <me@florianbigard.com>2018-04-19 11:01:34 +0200
commit0883b3245bf0deb9106c4041e9afbd3521b79280 (patch)
treefcb73005e0b31a3b763ee5d22d5fc39c2da89907 /server/helpers/custom-validators/users.ts
parent04ed10b21e8e1339514faae0bb690e4d97c23b0a (diff)
downloadPeerTube-0883b3245bf0deb9106c4041e9afbd3521b79280.tar.gz
PeerTube-0883b3245bf0deb9106c4041e9afbd3521b79280.tar.zst
PeerTube-0883b3245bf0deb9106c4041e9afbd3521b79280.zip
Add ability to choose what policy we have for NSFW videos
There is a global instance setting and a per user setting
Diffstat (limited to 'server/helpers/custom-validators/users.ts')
-rw-r--r--server/helpers/custom-validators/users.ts10
1 files changed, 6 insertions, 4 deletions
diff --git a/server/helpers/custom-validators/users.ts b/server/helpers/custom-validators/users.ts
index bbc7cc199..c0acb8218 100644
--- a/server/helpers/custom-validators/users.ts
+++ b/server/helpers/custom-validators/users.ts
@@ -1,9 +1,10 @@
1import 'express-validator' 1import 'express-validator'
2import * as validator from 'validator' 2import * as validator from 'validator'
3import { UserRole } from '../../../shared' 3import { UserRole } from '../../../shared'
4import { CONSTRAINTS_FIELDS } from '../../initializers' 4import { CONSTRAINTS_FIELDS, NSFW_POLICY_TYPES } from '../../initializers'
5 5
6import { exists, isFileValid } from './misc' 6import { exists, isFileValid } from './misc'
7import { values } from 'lodash'
7 8
8const USERS_CONSTRAINTS_FIELDS = CONSTRAINTS_FIELDS.USERS 9const USERS_CONSTRAINTS_FIELDS = CONSTRAINTS_FIELDS.USERS
9 10
@@ -29,8 +30,9 @@ function isBoolean (value: any) {
29 return typeof value === 'boolean' || (typeof value === 'string' && validator.isBoolean(value)) 30 return typeof value === 'boolean' || (typeof value === 'string' && validator.isBoolean(value))
30} 31}
31 32
32function isUserDisplayNSFWValid (value: any) { 33const nsfwPolicies = values(NSFW_POLICY_TYPES)
33 return isBoolean(value) 34function isUserNSFWPolicyValid (value: any) {
35 return exists(value) && nsfwPolicies.indexOf(value) !== -1
34} 36}
35 37
36function isUserAutoPlayVideoValid (value: any) { 38function isUserAutoPlayVideoValid (value: any) {
@@ -56,7 +58,7 @@ export {
56 isUserRoleValid, 58 isUserRoleValid,
57 isUserVideoQuotaValid, 59 isUserVideoQuotaValid,
58 isUserUsernameValid, 60 isUserUsernameValid,
59 isUserDisplayNSFWValid, 61 isUserNSFWPolicyValid,
60 isUserAutoPlayVideoValid, 62 isUserAutoPlayVideoValid,
61 isUserDescriptionValid, 63 isUserDescriptionValid,
62 isAvatarFile 64 isAvatarFile