aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2018-10-01 16:27:47 +0200
committerChocobozzz <me@florianbigard.com>2018-10-01 16:27:47 +0200
commita3737cbf2b09d5ce75e50f333d989a6162b04720 (patch)
treeb70091c20ff0b57513f40bb703509352bba296e3
parentd382f4e9175c1520835e41c3573471a84bcf1713 (diff)
downloadPeerTube-a3737cbf2b09d5ce75e50f333d989a6162b04720.tar.gz
PeerTube-a3737cbf2b09d5ce75e50f333d989a6162b04720.tar.zst
PeerTube-a3737cbf2b09d5ce75e50f333d989a6162b04720.zip
Fix video fps validator
-rw-r--r--server/helpers/custom-validators/activitypub/videos.ts2
-rw-r--r--server/lib/activitypub/videos.ts6
2 files changed, 4 insertions, 4 deletions
diff --git a/server/helpers/custom-validators/activitypub/videos.ts b/server/helpers/custom-validators/activitypub/videos.ts
index 8772e74cf..f88d26561 100644
--- a/server/helpers/custom-validators/activitypub/videos.ts
+++ b/server/helpers/custom-validators/activitypub/videos.ts
@@ -85,7 +85,7 @@ function isRemoteVideoUrlValid (url: any) {
85 isActivityPubUrlValid(url.href) && 85 isActivityPubUrlValid(url.href) &&
86 validator.isInt(url.height + '', { min: 0 }) && 86 validator.isInt(url.height + '', { min: 0 }) &&
87 validator.isInt(url.size + '', { min: 0 }) && 87 validator.isInt(url.size + '', { min: 0 }) &&
88 (!url.fps || validator.isInt(url.fps + '', { min: 0 })) 88 (!url.fps || validator.isInt(url.fps + '', { min: -1 }))
89 ) || 89 ) ||
90 ( 90 (
91 ACTIVITY_PUB.URL_MIME_TYPES.TORRENT.indexOf(url.mimeType) !== -1 && 91 ACTIVITY_PUB.URL_MIME_TYPES.TORRENT.indexOf(url.mimeType) !== -1 &&
diff --git a/server/lib/activitypub/videos.ts b/server/lib/activitypub/videos.ts
index 34685b6b1..cd1bc4e06 100644
--- a/server/lib/activitypub/videos.ts
+++ b/server/lib/activitypub/videos.ts
@@ -455,11 +455,11 @@ async function videoActivityObjectToDBAttributes (
455 } 455 }
456} 456}
457 457
458function videoFileActivityUrlToDBAttributes (videoCreated: VideoModel, videoObject: VideoTorrentObject) { 458function videoFileActivityUrlToDBAttributes (video: VideoModel, videoObject: VideoTorrentObject) {
459 const fileUrls = videoObject.url.filter(u => isActivityVideoUrlObject(u)) as ActivityVideoUrlObject[] 459 const fileUrls = videoObject.url.filter(u => isActivityVideoUrlObject(u)) as ActivityVideoUrlObject[]
460 460
461 if (fileUrls.length === 0) { 461 if (fileUrls.length === 0) {
462 throw new Error('Cannot find video files for ' + videoCreated.url) 462 throw new Error('Cannot find video files for ' + video.url)
463 } 463 }
464 464
465 const attributes: VideoFileModel[] = [] 465 const attributes: VideoFileModel[] = []
@@ -481,7 +481,7 @@ function videoFileActivityUrlToDBAttributes (videoCreated: VideoModel, videoObje
481 infoHash: parsed.infoHash, 481 infoHash: parsed.infoHash,
482 resolution: fileUrl.height, 482 resolution: fileUrl.height,
483 size: fileUrl.size, 483 size: fileUrl.size,
484 videoId: videoCreated.id, 484 videoId: video.id,
485 fps: fileUrl.fps || -1 485 fps: fileUrl.fps || -1
486 } as VideoFileModel 486 } as VideoFileModel
487 attributes.push(attribute) 487 attributes.push(attribute)