From 2baea0c77cc765f7cbca9c9a2f4272268892a35c Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Thu, 14 Jun 2018 18:06:56 +0200 Subject: Add ability for uploaders to schedule video update --- server/helpers/custom-validators/videos.ts | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) (limited to 'server/helpers/custom-validators') 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' import { values } from 'lodash' import 'multer' import * as validator from 'validator' -import { UserRight, VideoRateType } from '../../../shared' +import { UserRight, VideoPrivacy, VideoRateType } from '../../../shared' import { CONSTRAINTS_FIELDS, VIDEO_CATEGORIES, @@ -98,10 +98,18 @@ function isVideoImage (files: { [ fieldname: string ]: Express.Multer.File[] } | return isFileValid(files, videoImageTypesRegex, field, true) } -function isVideoPrivacyValid (value: string) { +function isVideoPrivacyValid (value: number) { return validator.isInt(value + '') && VIDEO_PRIVACIES[ value ] !== undefined } +function isScheduleVideoUpdatePrivacyValid (value: number) { + return validator.isInt(value + '') && + ( + value === VideoPrivacy.UNLISTED || + value === VideoPrivacy.PUBLIC + ) +} + function isVideoFileInfoHashValid (value: string) { return exists(value) && validator.isLength(value, VIDEOS_CONSTRAINTS_FIELDS.INFO_HASH) } @@ -174,6 +182,7 @@ export { isVideoFileInfoHashValid, isVideoNameValid, isVideoTagsValid, + isScheduleVideoUpdatePrivacyValid, isVideoAbuseReasonValid, isVideoFile, isVideoStateValid, -- cgit v1.2.3