aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/lib
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/lib
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/lib')
-rw-r--r--server/lib/video-comment.ts5
1 files changed, 3 insertions, 2 deletions
diff --git a/server/lib/video-comment.ts b/server/lib/video-comment.ts
index c76570a5d..02f160fe8 100644
--- a/server/lib/video-comment.ts
+++ b/server/lib/video-comment.ts
@@ -1,5 +1,6 @@
1import { cloneDeep } from 'lodash' 1import { cloneDeep } from 'lodash'
2import * as Sequelize from 'sequelize' 2import * as Sequelize from 'sequelize'
3import express from 'express'
3import { logger } from '@server/helpers/logger' 4import { logger } from '@server/helpers/logger'
4import { sequelizeTypescript } from '@server/initializers/database' 5import { sequelizeTypescript } from '@server/initializers/database'
5import { ResultList } from '../../shared/models' 6import { ResultList } from '../../shared/models'
@@ -10,7 +11,7 @@ import { sendCreateVideoComment, sendDeleteVideoComment } from './activitypub/se
10import { getLocalVideoCommentActivityPubUrl } from './activitypub/url' 11import { getLocalVideoCommentActivityPubUrl } from './activitypub/url'
11import { Hooks } from './plugins/hooks' 12import { Hooks } from './plugins/hooks'
12 13
13async function removeComment (videoCommentInstance: MCommentOwnerVideo) { 14async function removeComment (videoCommentInstance: MCommentOwnerVideo, req: express.Request, res: express.Response) {
14 const videoCommentInstanceBefore = cloneDeep(videoCommentInstance) 15 const videoCommentInstanceBefore = cloneDeep(videoCommentInstance)
15 16
16 await sequelizeTypescript.transaction(async t => { 17 await sequelizeTypescript.transaction(async t => {
@@ -25,7 +26,7 @@ async function removeComment (videoCommentInstance: MCommentOwnerVideo) {
25 26
26 logger.info('Video comment %d deleted.', videoCommentInstance.id) 27 logger.info('Video comment %d deleted.', videoCommentInstance.id)
27 28
28 Hooks.runAction('action:api.video-comment.deleted', { comment: videoCommentInstanceBefore }) 29 Hooks.runAction('action:api.video-comment.deleted', { comment: videoCommentInstanceBefore, req, res })
29} 30}
30 31
31async function createVideoComment (obj: { 32async function createVideoComment (obj: {