aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/controllers/api/videos/index.ts
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2021-06-11 09:57:19 +0200
committerChocobozzz <me@florianbigard.com>2021-06-11 09:57:19 +0200
commitca4b4b2e5590c1b37cff1fe1be7f797b93351229 (patch)
treee454de8be7b0dd6c28b08f27234fe6992ab9929c /server/controllers/api/videos/index.ts
parent1d43c3a613c72d69f7360fee9e5bfe6f662d62f7 (diff)
downloadPeerTube-ca4b4b2e5590c1b37cff1fe1be7f797b93351229.tar.gz
PeerTube-ca4b4b2e5590c1b37cff1fe1be7f797b93351229.tar.zst
PeerTube-ca4b4b2e5590c1b37cff1fe1be7f797b93351229.zip
Fetch directly all video attributes for get API
Diffstat (limited to 'server/controllers/api/videos/index.ts')
-rw-r--r--server/controllers/api/videos/index.ts11
1 files changed, 2 insertions, 9 deletions
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',
100videosRouter.get('/:id', 100videosRouter.get('/:id',
101 openapiOperationDoc({ operationId: 'getVideo' }), 101 openapiOperationDoc({ operationId: 'getVideo' }),
102 optionalAuthenticate, 102 optionalAuthenticate,
103 asyncMiddleware(videosCustomGetValidator('only-video-with-rights')), 103 asyncMiddleware(videosCustomGetValidator('for-api')),
104 asyncMiddleware(checkVideoFollowConstraints), 104 asyncMiddleware(checkVideoFollowConstraints),
105 asyncMiddleware(getVideo) 105 asyncMiddleware(getVideo)
106) 106)
@@ -142,14 +142,7 @@ function listVideoPrivacies (_req: express.Request, res: express.Response) {
142} 142}
143 143
144async function getVideo (_req: express.Request, res: express.Response) { 144async function getVideo (_req: express.Request, res: express.Response) {
145 // We need more attributes 145 const video = res.locals.videoAPI
146 const userId: number = res.locals.oauth ? res.locals.oauth.token.User.id : null
147
148 const video = await Hooks.wrapPromiseFun(
149 VideoModel.loadForGetAPI,
150 { id: _req.params.id, userId },
151 'filter:api.video.get.result'
152 )
153 146
154 if (video.isOutdated()) { 147 if (video.isOutdated()) {
155 JobQueue.Instance.createJob({ type: 'activitypub-refresher', payload: { type: 'video', url: video.url } }) 148 JobQueue.Instance.createJob({ type: 'activitypub-refresher', payload: { type: 'video', url: video.url } })