X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=server%2Fhelpers%2Fcustom-validators%2Fvideos.ts;h=5b9102275cebac16b4d7e5d842441f3efbdc3406;hb=9567011bf01f36c7f796ac1e0f1fb12c71635e53;hp=05d1dc60744eac1457d496f2afa3383f7584e278;hpb=35bf0c83c80f59ca79f4b84fac8700f17adeb22d;p=github%2FChocobozzz%2FPeerTube.git diff --git a/server/helpers/custom-validators/videos.ts b/server/helpers/custom-validators/videos.ts index 05d1dc607..5b9102275 100644 --- a/server/helpers/custom-validators/videos.ts +++ b/server/helpers/custom-validators/videos.ts @@ -23,34 +23,41 @@ const VIDEOS_CONSTRAINTS_FIELDS = CONSTRAINTS_FIELDS.VIDEOS const VIDEO_ABUSES_CONSTRAINTS_FIELDS = CONSTRAINTS_FIELDS.VIDEO_ABUSES const VIDEO_EVENTS_CONSTRAINTS_FIELDS = CONSTRAINTS_FIELDS.VIDEO_EVENTS -function isVideoIdOrUUIDValid (value: string) { - return validator.isInt(value) || isVideoUUIDValid(value) -} - -function isVideoAuthorValid (value: string) { - return isUserUsernameValid(value) -} - -function isVideoDateValid (value: string) { - return exists(value) && validator.isISO8601(value) -} - function isVideoCategoryValid (value: number) { return VIDEO_CATEGORIES[value] !== undefined } +// Maybe we don't know the remote category, but that doesn't matter +function isRemoteVideoCategoryValid (value: string) { + return validator.isInt('' + value) +} + function isVideoLicenceValid (value: number) { return VIDEO_LICENCES[value] !== undefined } +// Maybe we don't know the remote licence, but that doesn't matter +function isRemoteVideoLicenceValid (value: string) { + return validator.isInt('' + value) +} + function isVideoLanguageValid (value: number) { return value === null || VIDEO_LANGUAGES[value] !== undefined } +// Maybe we don't know the remote language, but that doesn't matter +function isRemoteVideoLanguageValid (value: string) { + return validator.isInt('' + value) +} + function isVideoNSFWValid (value: any) { return typeof value === 'boolean' || (typeof value === 'string' && validator.isBoolean(value)) } +function isVideoTruncatedDescriptionValid (value: string) { + return exists(value) && validator.isLength(value, VIDEOS_CONSTRAINTS_FIELDS.TRUNCATED_DESCRIPTION) +} + function isVideoDescriptionValid (value: string) { return exists(value) && validator.isLength(value, VIDEOS_CONSTRAINTS_FIELDS.DESCRIPTION) } @@ -79,10 +86,6 @@ function isVideoThumbnailDataValid (value: string) { return exists(value) && validator.isByteLength(value, VIDEOS_CONSTRAINTS_FIELDS.THUMBNAIL_DATA) } -function isVideoUUIDValid (value: string) { - return exists(value) && validator.isUUID('' + value, 4) -} - function isVideoAbuseReasonValid (value: string) { return exists(value) && validator.isLength(value, VIDEO_ABUSES_CONSTRAINTS_FIELDS.REASON) } @@ -170,13 +173,11 @@ function checkVideoExists (id: string, res: express.Response, callback: () => vo // --------------------------------------------------------------------------- export { - isVideoIdOrUUIDValid, - isVideoAuthorValid, - isVideoDateValid, isVideoCategoryValid, isVideoLicenceValid, isVideoLanguageValid, isVideoNSFWValid, + isVideoTruncatedDescriptionValid, isVideoDescriptionValid, isVideoDurationValid, isVideoFileInfoHashValid, @@ -185,7 +186,6 @@ export { isVideoThumbnailValid, isVideoThumbnailDataValid, isVideoFileExtnameValid, - isVideoUUIDValid, isVideoAbuseReasonValid, isVideoAbuseReporterUsernameValid, isVideoFile, @@ -196,5 +196,8 @@ export { isVideoEventCountValid, isVideoFileSizeValid, isVideoFileResolutionValid, - checkVideoExists + checkVideoExists, + isRemoteVideoCategoryValid, + isRemoteVideoLicenceValid, + isRemoteVideoLanguageValid }