X-Git-Url: https://git.librecmc.org/?a=blobdiff_plain;f=server%2Fhelpers%2Fcustom-validators%2Fvideos.js;h=be8256a80e9934e309b0dac4317a2a357b3a7dac;hb=feb4bdfd9b46e87aadfa7c0d5338cde887d1f58c;hp=1a7753265255994d592e1d6b44b4e5d00dde7f94;hpb=108626609eda75e4ecc0a83a650a4d53c46220e0;p=oweals%2Fpeertube.git diff --git a/server/helpers/custom-validators/videos.js b/server/helpers/custom-validators/videos.js index 1a7753265..be8256a80 100644 --- a/server/helpers/custom-validators/videos.js +++ b/server/helpers/custom-validators/videos.js @@ -13,7 +13,7 @@ const videosValidators = { isVideoDateValid, isVideoDescriptionValid, isVideoDurationValid, - isVideoMagnetValid, + isVideoInfoHashValid, isVideoNameValid, isVideoPodHostValid, isVideoTagsValid, @@ -28,14 +28,15 @@ function isEachRemoteVideosValid (requests) { return ( isRequestTypeAddValid(request.type) && isVideoAuthorValid(video.author) && - isVideoDateValid(video.createdDate) && + isVideoDateValid(video.createdAt) && isVideoDescriptionValid(video.description) && isVideoDurationValid(video.duration) && - isVideoMagnetValid(video.magnet) && + isVideoInfoHashValid(video.infoHash) && isVideoNameValid(video.name) && isVideoTagsValid(video.tags) && isVideoThumbnail64Valid(video.thumbnailBase64) && - isVideoRemoteIdValid(video.remoteId) + isVideoRemoteIdValid(video.remoteId) && + isVideoExtnameValid(video.extname) ) || ( isRequestTypeRemoveValid(request.type) && @@ -61,8 +62,12 @@ function isVideoDurationValid (value) { return validator.isInt(value + '', VIDEOS_CONSTRAINTS_FIELDS.DURATION) } -function isVideoMagnetValid (value) { - return validator.isLength(value.infoHash, VIDEOS_CONSTRAINTS_FIELDS.MAGNET.INFO_HASH) +function isVideoExtnameValid (value) { + return VIDEOS_CONSTRAINTS_FIELDS.EXTNAME.indexOf(value) !== -1 +} + +function isVideoInfoHashValid (value) { + return validator.isLength(value, VIDEOS_CONSTRAINTS_FIELDS.INFO_HASH) } function isVideoNameValid (value) { @@ -93,7 +98,7 @@ function isVideoThumbnail64Valid (value) { } function isVideoRemoteIdValid (value) { - return validator.isMongoId(value) + return validator.isUUID(value, 4) } // ---------------------------------------------------------------------------