diff options
author | Chocobozzz <me@florianbigard.com> | 2019-07-19 17:30:41 +0200 |
---|---|---|
committer | Chocobozzz <chocobozzz@cpy.re> | 2019-07-24 10:58:16 +0200 |
commit | 89cd12756035a146bbcc4db78cd3cd64f2f3d88d (patch) | |
tree | 896cd9fca1e0baa969b1f7a5b398ec1602761661 /server/controllers | |
parent | 09071200c73f5358e1d0bfb61a274e4f2c4ec52b (diff) | |
download | PeerTube-89cd12756035a146bbcc4db78cd3cd64f2f3d88d.tar.gz PeerTube-89cd12756035a146bbcc4db78cd3cd64f2f3d88d.tar.zst PeerTube-89cd12756035a146bbcc4db78cd3cd64f2f3d88d.zip |
Add hook filters tests
Diffstat (limited to 'server/controllers')
-rw-r--r-- | server/controllers/activitypub/client.ts | 2 | ||||
-rw-r--r-- | server/controllers/api/videos/comment.ts | 10 | ||||
-rw-r--r-- | server/controllers/api/videos/index.ts | 10 |
3 files changed, 13 insertions, 9 deletions
diff --git a/server/controllers/activitypub/client.ts b/server/controllers/activitypub/client.ts index d36d10de1..11504b354 100644 --- a/server/controllers/activitypub/client.ts +++ b/server/controllers/activitypub/client.ts | |||
@@ -208,7 +208,7 @@ function getAccountVideoRate (rateType: VideoRateType) { | |||
208 | 208 | ||
209 | async function videoController (req: express.Request, res: express.Response) { | 209 | async function videoController (req: express.Request, res: express.Response) { |
210 | // We need more attributes | 210 | // We need more attributes |
211 | const video = await VideoModel.loadForGetAPI(res.locals.video.id) | 211 | const video = await VideoModel.loadForGetAPI({ id: res.locals.video.id }) |
212 | 212 | ||
213 | if (video.url.startsWith(WEBSERVER.URL) === false) return res.redirect(video.url) | 213 | if (video.url.startsWith(WEBSERVER.URL) === false) return res.redirect(video.url) |
214 | 214 | ||
diff --git a/server/controllers/api/videos/comment.ts b/server/controllers/api/videos/comment.ts index a95392543..feda71bdd 100644 --- a/server/controllers/api/videos/comment.ts +++ b/server/controllers/api/videos/comment.ts | |||
@@ -85,8 +85,9 @@ async function listVideoThreads (req: express.Request, res: express.Response) { | |||
85 | user: user | 85 | user: user |
86 | }, 'filter:api.video-threads.list.params') | 86 | }, 'filter:api.video-threads.list.params') |
87 | 87 | ||
88 | resultList = await Hooks.wrapPromise( | 88 | resultList = await Hooks.wrapPromiseFun( |
89 | VideoCommentModel.listThreadsForApi(apiOptions), | 89 | VideoCommentModel.listThreadsForApi, |
90 | apiOptions, | ||
90 | 'filter:api.video-threads.list.result' | 91 | 'filter:api.video-threads.list.result' |
91 | ) | 92 | ) |
92 | } else { | 93 | } else { |
@@ -112,8 +113,9 @@ async function listVideoThreadComments (req: express.Request, res: express.Respo | |||
112 | user: user | 113 | user: user |
113 | }, 'filter:api.video-thread-comments.list.params') | 114 | }, 'filter:api.video-thread-comments.list.params') |
114 | 115 | ||
115 | resultList = await Hooks.wrapPromise( | 116 | resultList = await Hooks.wrapPromiseFun( |
116 | VideoCommentModel.listThreadCommentsForApi(apiOptions), | 117 | VideoCommentModel.listThreadCommentsForApi, |
118 | apiOptions, | ||
117 | 'filter:api.video-thread-comments.list.result' | 119 | 'filter:api.video-thread-comments.list.result' |
118 | ) | 120 | ) |
119 | } else { | 121 | } else { |
diff --git a/server/controllers/api/videos/index.ts b/server/controllers/api/videos/index.ts index a3b1dde29..11e468df2 100644 --- a/server/controllers/api/videos/index.ts +++ b/server/controllers/api/videos/index.ts | |||
@@ -436,8 +436,9 @@ async function getVideo (req: express.Request, res: express.Response) { | |||
436 | // We need more attributes | 436 | // We need more attributes |
437 | const userId: number = res.locals.oauth ? res.locals.oauth.token.User.id : null | 437 | const userId: number = res.locals.oauth ? res.locals.oauth.token.User.id : null |
438 | 438 | ||
439 | const video = await Hooks.wrapPromise( | 439 | const video = await Hooks.wrapPromiseFun( |
440 | VideoModel.loadForGetAPI(res.locals.video.id, undefined, userId), | 440 | VideoModel.loadForGetAPI, |
441 | { id: res.locals.video.id, userId }, | ||
441 | 'filter:api.video.get.result' | 442 | 'filter:api.video.get.result' |
442 | ) | 443 | ) |
443 | 444 | ||
@@ -502,8 +503,9 @@ async function listVideos (req: express.Request, res: express.Response) { | |||
502 | user: res.locals.oauth ? res.locals.oauth.token.User : undefined | 503 | user: res.locals.oauth ? res.locals.oauth.token.User : undefined |
503 | }, 'filter:api.videos.list.params') | 504 | }, 'filter:api.videos.list.params') |
504 | 505 | ||
505 | const resultList = await Hooks.wrapPromise( | 506 | const resultList = await Hooks.wrapPromiseFun( |
506 | VideoModel.listForApi(apiOptions), | 507 | VideoModel.listForApi, |
508 | apiOptions, | ||
507 | 'filter:api.videos.list.result' | 509 | 'filter:api.videos.list.result' |
508 | ) | 510 | ) |
509 | 511 | ||