From 9567011bf01f36c7f796ac1e0f1fb12c71635e53 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Mon, 30 Oct 2017 10:16:27 +0100 Subject: Add lazy description on server --- server/lib/friends.ts | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'server/lib/friends.ts') diff --git a/server/lib/friends.ts b/server/lib/friends.ts index 55cbb55b9..5c9baef47 100644 --- a/server/lib/friends.ts +++ b/server/lib/friends.ts @@ -349,6 +349,24 @@ function fetchRemotePreview (video: VideoInstance) { return request.get(REMOTE_SCHEME.HTTP + '://' + host + path) } +function fetchRemoteDescription (video: VideoInstance) { + const host = video.VideoChannel.Author.Pod.host + const path = video.getDescriptionPath() + + const requestOptions = { + url: REMOTE_SCHEME.HTTP + '://' + host + path, + json: true + } + + return new Promise((res, rej) => { + request.get(requestOptions, (err, response, body) => { + if (err) return rej(err) + + return res(body.description ? body.description : '') + }) + }) +} + async function removeFriend (pod: PodInstance) { const requestParams = { method: 'POST' as 'POST', @@ -407,6 +425,7 @@ export { getRequestVideoEventScheduler, fetchRemotePreview, addVideoChannelToFriends, + fetchRemoteDescription, updateVideoChannelToFriends, removeVideoChannelToFriends } -- cgit v1.2.3