From ca4b4b2e5590c1b37cff1fe1be7f797b93351229 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Fri, 11 Jun 2021 09:57:19 +0200 Subject: Fetch directly all video attributes for get API --- server/controllers/api/videos/index.ts | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) (limited to 'server/controllers/api/videos/index.ts') diff --git a/server/controllers/api/videos/index.ts b/server/controllers/api/videos/index.ts index 35992e993..5fdb7d5bc 100644 --- a/server/controllers/api/videos/index.ts +++ b/server/controllers/api/videos/index.ts @@ -100,7 +100,7 @@ videosRouter.get('/:id/metadata/:videoFileId', videosRouter.get('/:id', openapiOperationDoc({ operationId: 'getVideo' }), optionalAuthenticate, - asyncMiddleware(videosCustomGetValidator('only-video-with-rights')), + asyncMiddleware(videosCustomGetValidator('for-api')), asyncMiddleware(checkVideoFollowConstraints), asyncMiddleware(getVideo) ) @@ -142,14 +142,7 @@ function listVideoPrivacies (_req: express.Request, res: express.Response) { } async function getVideo (_req: express.Request, res: express.Response) { - // We need more attributes - const userId: number = res.locals.oauth ? res.locals.oauth.token.User.id : null - - const video = await Hooks.wrapPromiseFun( - VideoModel.loadForGetAPI, - { id: _req.params.id, userId }, - 'filter:api.video.get.result' - ) + const video = res.locals.videoAPI if (video.isOutdated()) { JobQueue.Instance.createJob({ type: 'activitypub-refresher', payload: { type: 'video', url: video.url } }) -- cgit v1.2.3