diff options
author | Chocobozzz <me@florianbigard.com> | 2018-06-14 18:06:56 +0200 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2018-06-14 18:06:56 +0200 |
commit | 2baea0c77cc765f7cbca9c9a2f4272268892a35c (patch) | |
tree | 47b1be5535439409a97eb80c0222c9c821b83dae /server/helpers/custom-validators/videos.ts | |
parent | bf079b7bfd7f0fb75ceb28e333bb4b74d8840dd4 (diff) | |
download | PeerTube-2baea0c77cc765f7cbca9c9a2f4272268892a35c.tar.gz PeerTube-2baea0c77cc765f7cbca9c9a2f4272268892a35c.tar.zst PeerTube-2baea0c77cc765f7cbca9c9a2f4272268892a35c.zip |
Add ability for uploaders to schedule video update
Diffstat (limited to 'server/helpers/custom-validators/videos.ts')
-rw-r--r-- | server/helpers/custom-validators/videos.ts | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/server/helpers/custom-validators/videos.ts b/server/helpers/custom-validators/videos.ts index 8496e679a..a227136ac 100644 --- a/server/helpers/custom-validators/videos.ts +++ b/server/helpers/custom-validators/videos.ts | |||
@@ -3,7 +3,7 @@ import 'express-validator' | |||
3 | import { values } from 'lodash' | 3 | import { values } from 'lodash' |
4 | import 'multer' | 4 | import 'multer' |
5 | import * as validator from 'validator' | 5 | import * as validator from 'validator' |
6 | import { UserRight, VideoRateType } from '../../../shared' | 6 | import { UserRight, VideoPrivacy, VideoRateType } from '../../../shared' |
7 | import { | 7 | import { |
8 | CONSTRAINTS_FIELDS, | 8 | CONSTRAINTS_FIELDS, |
9 | VIDEO_CATEGORIES, | 9 | VIDEO_CATEGORIES, |
@@ -98,10 +98,18 @@ function isVideoImage (files: { [ fieldname: string ]: Express.Multer.File[] } | | |||
98 | return isFileValid(files, videoImageTypesRegex, field, true) | 98 | return isFileValid(files, videoImageTypesRegex, field, true) |
99 | } | 99 | } |
100 | 100 | ||
101 | function isVideoPrivacyValid (value: string) { | 101 | function isVideoPrivacyValid (value: number) { |
102 | return validator.isInt(value + '') && VIDEO_PRIVACIES[ value ] !== undefined | 102 | return validator.isInt(value + '') && VIDEO_PRIVACIES[ value ] !== undefined |
103 | } | 103 | } |
104 | 104 | ||
105 | function isScheduleVideoUpdatePrivacyValid (value: number) { | ||
106 | return validator.isInt(value + '') && | ||
107 | ( | ||
108 | value === VideoPrivacy.UNLISTED || | ||
109 | value === VideoPrivacy.PUBLIC | ||
110 | ) | ||
111 | } | ||
112 | |||
105 | function isVideoFileInfoHashValid (value: string) { | 113 | function isVideoFileInfoHashValid (value: string) { |
106 | return exists(value) && validator.isLength(value, VIDEOS_CONSTRAINTS_FIELDS.INFO_HASH) | 114 | return exists(value) && validator.isLength(value, VIDEOS_CONSTRAINTS_FIELDS.INFO_HASH) |
107 | } | 115 | } |
@@ -174,6 +182,7 @@ export { | |||
174 | isVideoFileInfoHashValid, | 182 | isVideoFileInfoHashValid, |
175 | isVideoNameValid, | 183 | isVideoNameValid, |
176 | isVideoTagsValid, | 184 | isVideoTagsValid, |
185 | isScheduleVideoUpdatePrivacyValid, | ||
177 | isVideoAbuseReasonValid, | 186 | isVideoAbuseReasonValid, |
178 | isVideoFile, | 187 | isVideoFile, |
179 | isVideoStateValid, | 188 | isVideoStateValid, |