diff options
author | lutangar <johan.dufour@gmail.com> | 2021-11-24 14:33:14 +0100 |
---|---|---|
committer | Chocobozzz <chocobozzz@cpy.re> | 2021-11-25 09:54:22 +0100 |
commit | 7226e90fdc61a3c6cad5ccab18b6707d55cf0992 (patch) | |
tree | 0bdd7304352b1af2d9ae87439486a138e02d46e8 /server/controllers/api/videos/index.ts | |
parent | 5098098d96164c93f84ec8419e98fbd83ba8dc71 (diff) | |
download | PeerTube-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/index.ts')
-rw-r--r-- | server/controllers/api/videos/index.ts | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/server/controllers/api/videos/index.ts b/server/controllers/api/videos/index.ts index fc1bcc73d..61a030ba1 100644 --- a/server/controllers/api/videos/index.ts +++ b/server/controllers/api/videos/index.ts | |||
@@ -158,7 +158,7 @@ async function viewVideo (req: express.Request, res: express.Response) { | |||
158 | const serverActor = await getServerActor() | 158 | const serverActor = await getServerActor() |
159 | await sendView(serverActor, video, undefined) | 159 | await sendView(serverActor, video, undefined) |
160 | 160 | ||
161 | Hooks.runAction('action:api.video.viewed', { video: video, ip }) | 161 | Hooks.runAction('action:api.video.viewed', { video: video, ip, req, res }) |
162 | } | 162 | } |
163 | 163 | ||
164 | return res.status(HttpStatusCode.NO_CONTENT_204).end() | 164 | return res.status(HttpStatusCode.NO_CONTENT_204).end() |
@@ -201,7 +201,7 @@ async function listVideos (req: express.Request, res: express.Response) { | |||
201 | return res.json(getFormattedObjects(resultList.data, resultList.total, guessAdditionalAttributesFromQuery(query))) | 201 | return res.json(getFormattedObjects(resultList.data, resultList.total, guessAdditionalAttributesFromQuery(query))) |
202 | } | 202 | } |
203 | 203 | ||
204 | async function removeVideo (_req: express.Request, res: express.Response) { | 204 | async function removeVideo (req: express.Request, res: express.Response) { |
205 | const videoInstance = res.locals.videoAll | 205 | const videoInstance = res.locals.videoAll |
206 | 206 | ||
207 | await sequelizeTypescript.transaction(async t => { | 207 | await sequelizeTypescript.transaction(async t => { |
@@ -211,7 +211,7 @@ async function removeVideo (_req: express.Request, res: express.Response) { | |||
211 | auditLogger.delete(getAuditIdFromRes(res), new VideoAuditView(videoInstance.toFormattedDetailsJSON())) | 211 | auditLogger.delete(getAuditIdFromRes(res), new VideoAuditView(videoInstance.toFormattedDetailsJSON())) |
212 | logger.info('Video with name %s and uuid %s deleted.', videoInstance.name, videoInstance.uuid) | 212 | logger.info('Video with name %s and uuid %s deleted.', videoInstance.name, videoInstance.uuid) |
213 | 213 | ||
214 | Hooks.runAction('action:api.video.deleted', { video: videoInstance }) | 214 | Hooks.runAction('action:api.video.deleted', { video: videoInstance, req, res }) |
215 | 215 | ||
216 | return res.type('json') | 216 | return res.type('json') |
217 | .status(HttpStatusCode.NO_CONTENT_204) | 217 | .status(HttpStatusCode.NO_CONTENT_204) |