]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blobdiff - server/helpers/custom-validators/videos.ts
Update server dependencies
[github/Chocobozzz/PeerTube.git] / server / helpers / custom-validators / videos.ts
index ca5f70fdc2e8574dc52c7a5207afc14fe039eb74..5f75ec27c8a0b43f29ffbaf1897619d5cd722e40 100644 (file)
@@ -1,6 +1,5 @@
 import { UploadFilesForCheck } from 'express'
-import { values } from 'lodash'
-import magnetUtil from 'magnet-uri'
+import { decode as magnetUriDecode } from 'magnet-uri'
 import validator from 'validator'
 import { VideoFilter, VideoInclude, VideoPrivacy, VideoRateType } from '@shared/models'
 import {
@@ -46,10 +45,6 @@ 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)
-}
-
 function isVideoDescriptionValid (value: string) {
   return value === null || (exists(value) && validator.isLength(value, VIDEOS_CONSTRAINTS_FIELDS.DESCRIPTION))
 }
@@ -78,8 +73,9 @@ function isVideoViewsValid (value: string) {
   return exists(value) && validator.isInt(value + '', VIDEOS_CONSTRAINTS_FIELDS.VIEWS)
 }
 
+const ratingTypes = new Set(Object.values(VIDEO_RATE_TYPES))
 function isVideoRatingTypeValid (value: string) {
-  return value === 'none' || values(VIDEO_RATE_TYPES).includes(value as VideoRateType)
+  return value === 'none' || ratingTypes.has(value as VideoRateType)
 }
 
 function isVideoFileExtnameValid (value: string) {
@@ -141,7 +137,7 @@ function isVideoFileSizeValid (value: string) {
 function isVideoMagnetUriValid (value: string) {
   if (!exists(value)) return false
 
-  const parsed = magnetUtil.decode(value)
+  const parsed = magnetUriDecode(value)
   return parsed && isVideoFileInfoHashValid(parsed.infoHash)
 }
 
@@ -151,7 +147,6 @@ export {
   isVideoCategoryValid,
   isVideoLicenceValid,
   isVideoLanguageValid,
-  isVideoTruncatedDescriptionValid,
   isVideoDescriptionValid,
   isVideoFileInfoHashValid,
   isVideoNameValid,