aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/controllers/api/videos/upload.ts
diff options
context:
space:
mode:
authorlutangar <johan.dufour@gmail.com>2021-11-24 14:33:14 +0100
committerChocobozzz <chocobozzz@cpy.re>2021-11-25 09:54:22 +0100
commit7226e90fdc61a3c6cad5ccab18b6707d55cf0992 (patch)
tree0bdd7304352b1af2d9ae87439486a138e02d46e8 /server/controllers/api/videos/upload.ts
parent5098098d96164c93f84ec8419e98fbd83ba8dc71 (diff)
downloadPeerTube-7226e90fdc61a3c6cad5ccab18b6707d55cf0992.tar.gz
PeerTube-7226e90fdc61a3c6cad5ccab18b6707d55cf0992.tar.zst
PeerTube-7226e90fdc61a3c6cad5ccab18b6707d55cf0992.zip
Add `req` and `res` as controllers hooks parameters
Hooks prefixed by `action:api` now give access the original express req and res. Checkout guide.md for possible usage.
Diffstat (limited to 'server/controllers/api/videos/upload.ts')
-rw-r--r--server/controllers/api/videos/upload.ts9
1 files changed, 5 insertions, 4 deletions
diff --git a/server/controllers/api/videos/upload.ts b/server/controllers/api/videos/upload.ts
index 3e9979330..6773b500f 100644
--- a/server/controllers/api/videos/upload.ts
+++ b/server/controllers/api/videos/upload.ts
@@ -129,7 +129,7 @@ async function addVideoLegacy (req: express.Request, res: express.Response) {
129 const videoInfo: VideoCreate = req.body 129 const videoInfo: VideoCreate = req.body
130 const files = req.files 130 const files = req.files
131 131
132 const response = await addVideo({ res, videoPhysicalFile, videoInfo, files }) 132 const response = await addVideo({ req, res, videoPhysicalFile, videoInfo, files })
133 133
134 return res.json(response) 134 return res.json(response)
135} 135}
@@ -139,19 +139,20 @@ async function addVideoResumable (req: express.Request, res: express.Response) {
139 const videoInfo = videoPhysicalFile.metadata 139 const videoInfo = videoPhysicalFile.metadata
140 const files = { previewfile: videoInfo.previewfile } 140 const files = { previewfile: videoInfo.previewfile }
141 141
142 const response = await addVideo({ res, videoPhysicalFile, videoInfo, files }) 142 const response = await addVideo({ req, res, videoPhysicalFile, videoInfo, files })
143 await Redis.Instance.setUploadSession(req.query.upload_id, response) 143 await Redis.Instance.setUploadSession(req.query.upload_id, response)
144 144
145 return res.json(response) 145 return res.json(response)
146} 146}
147 147
148async function addVideo (options: { 148async function addVideo (options: {
149 req: express.Request
149 res: express.Response 150 res: express.Response
150 videoPhysicalFile: express.VideoUploadFile 151 videoPhysicalFile: express.VideoUploadFile
151 videoInfo: VideoCreate 152 videoInfo: VideoCreate
152 files: express.UploadFiles 153 files: express.UploadFiles
153}) { 154}) {
154 const { res, videoPhysicalFile, videoInfo, files } = options 155 const { req, res, videoPhysicalFile, videoInfo, files } = options
155 const videoChannel = res.locals.videoChannel 156 const videoChannel = res.locals.videoChannel
156 const user = res.locals.oauth.token.User 157 const user = res.locals.oauth.token.User
157 158
@@ -235,7 +236,7 @@ async function addVideo (options: {
235 }) 236 })
236 .catch(err => logger.error('Cannot add optimize/merge audio job for %s.', videoCreated.uuid, { err, ...lTags(videoCreated.uuid) })) 237 .catch(err => logger.error('Cannot add optimize/merge audio job for %s.', videoCreated.uuid, { err, ...lTags(videoCreated.uuid) }))
237 238
238 Hooks.runAction('action:api.video.uploaded', { video: videoCreated }) 239 Hooks.runAction('action:api.video.uploaded', { video: videoCreated, req, res })
239 240
240 return { 241 return {
241 video: { 242 video: {