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/lib | |
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/lib')
-rw-r--r-- | server/lib/video-comment.ts | 5 |
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 @@ | |||
1 | import { cloneDeep } from 'lodash' | 1 | import { cloneDeep } from 'lodash' |
2 | import * as Sequelize from 'sequelize' | 2 | import * as Sequelize from 'sequelize' |
3 | import express from 'express' | ||
3 | import { logger } from '@server/helpers/logger' | 4 | import { logger } from '@server/helpers/logger' |
4 | import { sequelizeTypescript } from '@server/initializers/database' | 5 | import { sequelizeTypescript } from '@server/initializers/database' |
5 | import { ResultList } from '../../shared/models' | 6 | import { ResultList } from '../../shared/models' |
@@ -10,7 +11,7 @@ import { sendCreateVideoComment, sendDeleteVideoComment } from './activitypub/se | |||
10 | import { getLocalVideoCommentActivityPubUrl } from './activitypub/url' | 11 | import { getLocalVideoCommentActivityPubUrl } from './activitypub/url' |
11 | import { Hooks } from './plugins/hooks' | 12 | import { Hooks } from './plugins/hooks' |
12 | 13 | ||
13 | async function removeComment (videoCommentInstance: MCommentOwnerVideo) { | 14 | async 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 | ||
31 | async function createVideoComment (obj: { | 32 | async function createVideoComment (obj: { |