Fix video fps validator
authorChocobozzz <me@florianbigard.com>
Mon, 1 Oct 2018 14:27:47 +0000 (16:27 +0200)
committerChocobozzz <me@florianbigard.com>
Mon, 1 Oct 2018 14:27:47 +0000 (16:27 +0200)
server/helpers/custom-validators/activitypub/videos.ts
server/lib/activitypub/videos.ts

index 8772e74cfef2630814ab6ddca3002fb76e9540a7..f88d265610f5e9620c83d0bb7e67051414c351d9 100644 (file)
@@ -85,7 +85,7 @@ function isRemoteVideoUrlValid (url: any) {
       isActivityPubUrlValid(url.href) &&
       validator.isInt(url.height + '', { min: 0 }) &&
       validator.isInt(url.size + '', { min: 0 }) &&
-      (!url.fps || validator.isInt(url.fps + '', { min: 0 }))
+      (!url.fps || validator.isInt(url.fps + '', { min: -1 }))
     ) ||
     (
       ACTIVITY_PUB.URL_MIME_TYPES.TORRENT.indexOf(url.mimeType) !== -1 &&
index 34685b6b1c4cce4c49225d2a8e6974aa8215bce5..cd1bc4e063bd9fcebac960d10515aeb8f1e71ad7 100644 (file)
@@ -455,11 +455,11 @@ async function videoActivityObjectToDBAttributes (
   }
 }
 
-function videoFileActivityUrlToDBAttributes (videoCreated: VideoModel, videoObject: VideoTorrentObject) {
+function videoFileActivityUrlToDBAttributes (video: VideoModel, videoObject: VideoTorrentObject) {
   const fileUrls = videoObject.url.filter(u => isActivityVideoUrlObject(u)) as ActivityVideoUrlObject[]
 
   if (fileUrls.length === 0) {
-    throw new Error('Cannot find video files for ' + videoCreated.url)
+    throw new Error('Cannot find video files for ' + video.url)
   }
 
   const attributes: VideoFileModel[] = []
@@ -481,7 +481,7 @@ function videoFileActivityUrlToDBAttributes (videoCreated: VideoModel, videoObje
       infoHash: parsed.infoHash,
       resolution: fileUrl.height,
       size: fileUrl.size,
-      videoId: videoCreated.id,
+      videoId: video.id,
       fps: fileUrl.fps || -1
     } as VideoFileModel
     attributes.push(attribute)