aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/lib
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2017-12-27 20:03:37 +0100
committerChocobozzz <me@florianbigard.com>2017-12-27 20:03:37 +0100
commitd50acfab69ce9e05b272dea6c4d34d52960ba14c (patch)
tree55ce8b70777603b772d2cecb96cd71aac9ccfb9c /server/lib
parentae45f988bb5ea32152cca02a282d02599dbb633b (diff)
downloadPeerTube-d50acfab69ce9e05b272dea6c4d34d52960ba14c.tar.gz
PeerTube-d50acfab69ce9e05b272dea6c4d34d52960ba14c.tar.zst
PeerTube-d50acfab69ce9e05b272dea6c4d34d52960ba14c.zip
Add comments federation tests
Diffstat (limited to 'server/lib')
-rw-r--r--server/lib/activitypub/videos.ts4
-rw-r--r--server/lib/cache/videos-preview-cache.ts10
2 files changed, 6 insertions, 8 deletions
diff --git a/server/lib/activitypub/videos.ts b/server/lib/activitypub/videos.ts
index fab43757a..ded854ee1 100644
--- a/server/lib/activitypub/videos.ts
+++ b/server/lib/activitypub/videos.ts
@@ -17,12 +17,12 @@ import {
17 sendUndoLikeToVideoFollowers 17 sendUndoLikeToVideoFollowers
18} from './send' 18} from './send'
19 19
20function fetchRemoteVideoPreview (video: VideoModel) { 20function fetchRemoteVideoPreview (video: VideoModel, reject: Function) {
21 // FIXME: use url 21 // FIXME: use url
22 const host = video.VideoChannel.Account.Actor.Server.host 22 const host = video.VideoChannel.Account.Actor.Server.host
23 const path = join(STATIC_PATHS.PREVIEWS, video.getPreviewName()) 23 const path = join(STATIC_PATHS.PREVIEWS, video.getPreviewName())
24 24
25 return request.get(REMOTE_SCHEME.HTTP + '://' + host + path) 25 return request.get(REMOTE_SCHEME.HTTP + '://' + host + path, err => reject(err))
26} 26}
27 27
28async function fetchRemoteVideoDescription (video: VideoModel) { 28async function fetchRemoteVideoDescription (video: VideoModel) {
diff --git a/server/lib/cache/videos-preview-cache.ts b/server/lib/cache/videos-preview-cache.ts
index 0eb43efcc..ea959076d 100644
--- a/server/lib/cache/videos-preview-cache.ts
+++ b/server/lib/cache/videos-preview-cache.ts
@@ -52,21 +52,19 @@ class VideosPreviewCache {
52 52
53 if (video.isOwned()) throw new Error('Cannot load preview of owned video.') 53 if (video.isOwned()) throw new Error('Cannot load preview of owned video.')
54 54
55 const res = await this.saveRemotePreviewAndReturnPath(video) 55 return this.saveRemotePreviewAndReturnPath(video)
56
57 return res
58 } 56 }
59 57
60 private saveRemotePreviewAndReturnPath (video: VideoModel) { 58 private saveRemotePreviewAndReturnPath (video: VideoModel) {
61 const req = fetchRemoteVideoPreview(video)
62 59
63 return new Promise<string>((res, rej) => { 60 return new Promise<string>((res, rej) => {
61 const req = fetchRemoteVideoPreview(video, rej)
64 const path = join(CACHE.DIRECTORIES.PREVIEWS, video.getPreviewName()) 62 const path = join(CACHE.DIRECTORIES.PREVIEWS, video.getPreviewName())
65 const stream = createWriteStream(path) 63 const stream = createWriteStream(path)
66 64
67 req.pipe(stream) 65 req.pipe(stream)
68 .on('finish', () => res(path)) 66 .on('error', (err) => rej(err))
69 .on('error', (err) => rej(err)) 67 .on('finish', () => res(path))
70 }) 68 })
71 } 69 }
72} 70}