diff options
Diffstat (limited to 'server/controllers/api/videos/index.ts')
-rw-r--r-- | server/controllers/api/videos/index.ts | 21 |
1 files changed, 20 insertions, 1 deletions
diff --git a/server/controllers/api/videos/index.ts b/server/controllers/api/videos/index.ts index 9e233a8cc..49f0e4630 100644 --- a/server/controllers/api/videos/index.ts +++ b/server/controllers/api/videos/index.ts | |||
@@ -16,7 +16,8 @@ import { | |||
16 | quickAndDirtyUpdateVideoToFriends, | 16 | quickAndDirtyUpdateVideoToFriends, |
17 | addVideoToFriends, | 17 | addVideoToFriends, |
18 | updateVideoToFriends, | 18 | updateVideoToFriends, |
19 | JobScheduler | 19 | JobScheduler, |
20 | fetchRemoteDescription | ||
20 | } from '../../../lib' | 21 | } from '../../../lib' |
21 | import { | 22 | import { |
22 | authenticate, | 23 | authenticate, |
@@ -102,6 +103,11 @@ videosRouter.post('/upload', | |||
102 | videosAddValidator, | 103 | videosAddValidator, |
103 | asyncMiddleware(addVideoRetryWrapper) | 104 | asyncMiddleware(addVideoRetryWrapper) |
104 | ) | 105 | ) |
106 | |||
107 | videosRouter.get('/:id/description', | ||
108 | videosGetValidator, | ||
109 | asyncMiddleware(getVideoDescription) | ||
110 | ) | ||
105 | videosRouter.get('/:id', | 111 | videosRouter.get('/:id', |
106 | videosGetValidator, | 112 | videosGetValidator, |
107 | getVideo | 113 | getVideo |
@@ -328,6 +334,19 @@ function getVideo (req: express.Request, res: express.Response) { | |||
328 | return res.json(videoInstance.toFormattedDetailsJSON()) | 334 | return res.json(videoInstance.toFormattedDetailsJSON()) |
329 | } | 335 | } |
330 | 336 | ||
337 | async function getVideoDescription (req: express.Request, res: express.Response) { | ||
338 | const videoInstance = res.locals.video | ||
339 | let description = '' | ||
340 | |||
341 | if (videoInstance.isOwned()) { | ||
342 | description = videoInstance.description | ||
343 | } else { | ||
344 | description = await fetchRemoteDescription(videoInstance) | ||
345 | } | ||
346 | |||
347 | return res.json({ description }) | ||
348 | } | ||
349 | |||
331 | async function listVideos (req: express.Request, res: express.Response, next: express.NextFunction) { | 350 | async function listVideos (req: express.Request, res: express.Response, next: express.NextFunction) { |
332 | const resultList = await db.Video.listForApi(req.query.start, req.query.count, req.query.sort) | 351 | const resultList = await db.Video.listForApi(req.query.start, req.query.count, req.query.sort) |
333 | 352 | ||