mirror of
https://github.com/Chocobozzz/PeerTube.git
synced 2025-10-06 03:50:26 +02:00
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.
This commit is contained in:
parent
5098098d96
commit
7226e90fdc
12 changed files with 41 additions and 23 deletions
|
@ -158,7 +158,7 @@ async function viewVideo (req: express.Request, res: express.Response) {
|
|||
const serverActor = await getServerActor()
|
||||
await sendView(serverActor, video, undefined)
|
||||
|
||||
Hooks.runAction('action:api.video.viewed', { video: video, ip })
|
||||
Hooks.runAction('action:api.video.viewed', { video: video, ip, req, res })
|
||||
}
|
||||
|
||||
return res.status(HttpStatusCode.NO_CONTENT_204).end()
|
||||
|
@ -201,7 +201,7 @@ async function listVideos (req: express.Request, res: express.Response) {
|
|||
return res.json(getFormattedObjects(resultList.data, resultList.total, guessAdditionalAttributesFromQuery(query)))
|
||||
}
|
||||
|
||||
async function removeVideo (_req: express.Request, res: express.Response) {
|
||||
async function removeVideo (req: express.Request, res: express.Response) {
|
||||
const videoInstance = res.locals.videoAll
|
||||
|
||||
await sequelizeTypescript.transaction(async t => {
|
||||
|
@ -211,7 +211,7 @@ async function removeVideo (_req: express.Request, res: express.Response) {
|
|||
auditLogger.delete(getAuditIdFromRes(res), new VideoAuditView(videoInstance.toFormattedDetailsJSON()))
|
||||
logger.info('Video with name %s and uuid %s deleted.', videoInstance.name, videoInstance.uuid)
|
||||
|
||||
Hooks.runAction('action:api.video.deleted', { video: videoInstance })
|
||||
Hooks.runAction('action:api.video.deleted', { video: videoInstance, req, res })
|
||||
|
||||
return res.type('json')
|
||||
.status(HttpStatusCode.NO_CONTENT_204)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue