Fix video fps validator

This commit is contained in:
Chocobozzz 2018-10-01 16:27:47 +02:00
parent d382f4e917
commit a3737cbf2b
No known key found for this signature in database
GPG Key ID: 583A612D890159BE
2 changed files with 4 additions and 4 deletions

View File

@ -85,7 +85,7 @@ function isRemoteVideoUrlValid (url: any) {
isActivityPubUrlValid(url.href) && isActivityPubUrlValid(url.href) &&
validator.isInt(url.height + '', { min: 0 }) && validator.isInt(url.height + '', { min: 0 }) &&
validator.isInt(url.size + '', { 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 && ACTIVITY_PUB.URL_MIME_TYPES.TORRENT.indexOf(url.mimeType) !== -1 &&

View 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[] const fileUrls = videoObject.url.filter(u => isActivityVideoUrlObject(u)) as ActivityVideoUrlObject[]
if (fileUrls.length === 0) { 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[] = [] const attributes: VideoFileModel[] = []
@ -481,7 +481,7 @@ function videoFileActivityUrlToDBAttributes (videoCreated: VideoModel, videoObje
infoHash: parsed.infoHash, infoHash: parsed.infoHash,
resolution: fileUrl.height, resolution: fileUrl.height,
size: fileUrl.size, size: fileUrl.size,
videoId: videoCreated.id, videoId: video.id,
fps: fileUrl.fps || -1 fps: fileUrl.fps || -1
} as VideoFileModel } as VideoFileModel
attributes.push(attribute) attributes.push(attribute)