diff options
author | Chocobozzz <me@florianbigard.com> | 2021-06-11 09:57:19 +0200 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2021-06-11 09:57:19 +0200 |
commit | ca4b4b2e5590c1b37cff1fe1be7f797b93351229 (patch) | |
tree | e454de8be7b0dd6c28b08f27234fe6992ab9929c /server/controllers/api | |
parent | 1d43c3a613c72d69f7360fee9e5bfe6f662d62f7 (diff) | |
download | PeerTube-ca4b4b2e5590c1b37cff1fe1be7f797b93351229.tar.gz PeerTube-ca4b4b2e5590c1b37cff1fe1be7f797b93351229.tar.zst PeerTube-ca4b4b2e5590c1b37cff1fe1be7f797b93351229.zip |
Fetch directly all video attributes for get API
Diffstat (limited to 'server/controllers/api')
-rw-r--r-- | server/controllers/api/videos/index.ts | 11 |
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', | |||
100 | videosRouter.get('/:id', | 100 | videosRouter.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 | ||
144 | async function getVideo (_req: express.Request, res: express.Response) { | 144 | async 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 } }) |