From 8e10cf1a5a438a00e5f7e0691cb830769867cffc Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Wed, 15 Nov 2017 16:28:35 +0100 Subject: Fix video upload and videos list --- server/helpers/custom-validators/videos.ts | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) (limited to 'server/helpers/custom-validators/videos.ts') diff --git a/server/helpers/custom-validators/videos.ts b/server/helpers/custom-validators/videos.ts index 1505632da..c97c9a2ad 100644 --- a/server/helpers/custom-validators/videos.ts +++ b/server/helpers/custom-validators/videos.ts @@ -69,6 +69,10 @@ function isVideoNSFWValid (value: any) { return typeof value === 'boolean' || (typeof value === 'string' && validator.isBoolean(value)) } +function isVideoDurationValid (value: string) { + return exists(value) && validator.isInt(value + '', VIDEOS_CONSTRAINTS_FIELDS.DURATION) +} + function isVideoTruncatedDescriptionValid (value: string) { return exists(value) && validator.isLength(value, VIDEOS_CONSTRAINTS_FIELDS.TRUNCATED_DESCRIPTION) } @@ -77,15 +81,6 @@ function isVideoDescriptionValid (value: string) { return exists(value) && validator.isLength(value, VIDEOS_CONSTRAINTS_FIELDS.DESCRIPTION) } -function isVideoDurationValid (value: string) { - // https://www.w3.org/TR/activitystreams-vocabulary/#dfn-duration - return exists(value) && - typeof value === 'string' && - value.startsWith('PT') && - value.endsWith('S') && - validator.isInt(value.replace(/[^0-9]+/, ''), VIDEOS_CONSTRAINTS_FIELDS.DURATION) -} - function isVideoNameValid (value: string) { return exists(value) && validator.isLength(value, VIDEOS_CONSTRAINTS_FIELDS.NAME) } @@ -197,7 +192,6 @@ export { isVideoNSFWValid, isVideoTruncatedDescriptionValid, isVideoDescriptionValid, - isVideoDurationValid, isVideoFileInfoHashValid, isVideoNameValid, isVideoTagsValid, @@ -214,6 +208,7 @@ export { isVideoFileSizeValid, isVideoPrivacyValid, isRemoteVideoPrivacyValid, + isVideoDurationValid, isVideoFileResolutionValid, checkVideoExists, isVideoTagValid, -- cgit v1.2.3