Fix lint
[oweals/peertube.git] / server / lib / activitypub / videos.ts
index 708f4a8974b4acff8536245a2ecbe520f3f9404c..50e7e5cde4a3536cbb995c85264f9019315a5084 100644 (file)
@@ -1,4 +1,3 @@
-import * as Bluebird from 'bluebird'
 import * as magnetUtil from 'magnet-uri'
 import { join } from 'path'
 import * as request from 'request'
@@ -20,17 +19,16 @@ import { VideoShareModel } from '../../models/video/video-share'
 import { getOrCreateActorAndServerAndModel } from './actor'
 
 function fetchRemoteVideoPreview (video: VideoModel, reject: Function) {
-  // FIXME: use url
   const host = video.VideoChannel.Account.Actor.Server.host
   const path = join(STATIC_PATHS.PREVIEWS, video.getPreviewName())
 
+  // We need to provide a callback, if no we could have an uncaught exception
   return request.get(REMOTE_SCHEME.HTTP + '://' + host + path, err => {
     if (err) reject(err)
   })
 }
 
 async function fetchRemoteVideoDescription (video: VideoModel) {
-  // FIXME: use url
   const host = video.VideoChannel.Account.Actor.Server.host
   const path = video.getDescriptionPath()
   const options = {
@@ -122,10 +120,10 @@ function videoFileActivityUrlToDBAttributes (videoCreated: VideoModel, videoObje
       return u.mimeType === 'application/x-bittorrent;x-scheme-handler/magnet' && u.width === fileUrl.width
     })
 
-    if (!magnet) throw new Error('Cannot find associated magnet uri for file ' + fileUrl.url)
+    if (!magnet) throw new Error('Cannot find associated magnet uri for file ' + fileUrl.href)
 
-    const parsed = magnetUtil.decode(magnet.url)
-    if (!parsed || isVideoFileInfoHashValid(parsed.infoHash) === false) throw new Error('Cannot parse magnet URI ' + magnet.url)
+    const parsed = magnetUtil.decode(magnet.href)
+    if (!parsed || isVideoFileInfoHashValid(parsed.infoHash) === false) throw new Error('Cannot parse magnet URI ' + magnet.href)
 
     const attribute = {
       extname: VIDEO_MIMETYPE_EXT[ fileUrl.mimeType ],
@@ -164,7 +162,7 @@ async function getOrCreateVideo (videoObject: VideoTorrentObject, channelActor:
       throw new Error('Cannot find valid files for video %s ' + videoObject.url)
     }
 
-    const tasks: Bluebird<any>[] = videoFileAttributes.map(f => VideoFileModel.create(f, { transaction: t }))
+    const tasks = videoFileAttributes.map(f => VideoFileModel.create(f, { transaction: t }))
     await Promise.all(tasks)
 
     const tags = videoObject.tag.map(t => t.name)