From 89cd12756035a146bbcc4db78cd3cd64f2f3d88d Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Fri, 19 Jul 2019 17:30:41 +0200 Subject: Add hook filters tests --- server/controllers/activitypub/client.ts | 2 +- server/controllers/api/videos/comment.ts | 10 ++++++---- server/controllers/api/videos/index.ts | 10 ++++++---- 3 files changed, 13 insertions(+), 9 deletions(-) (limited to 'server/controllers') 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) { async function videoController (req: express.Request, res: express.Response) { // We need more attributes - const video = await VideoModel.loadForGetAPI(res.locals.video.id) + const video = await VideoModel.loadForGetAPI({ id: res.locals.video.id }) if (video.url.startsWith(WEBSERVER.URL) === false) return res.redirect(video.url) 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) { user: user }, 'filter:api.video-threads.list.params') - resultList = await Hooks.wrapPromise( - VideoCommentModel.listThreadsForApi(apiOptions), + resultList = await Hooks.wrapPromiseFun( + VideoCommentModel.listThreadsForApi, + apiOptions, 'filter:api.video-threads.list.result' ) } else { @@ -112,8 +113,9 @@ async function listVideoThreadComments (req: express.Request, res: express.Respo user: user }, 'filter:api.video-thread-comments.list.params') - resultList = await Hooks.wrapPromise( - VideoCommentModel.listThreadCommentsForApi(apiOptions), + resultList = await Hooks.wrapPromiseFun( + VideoCommentModel.listThreadCommentsForApi, + apiOptions, 'filter:api.video-thread-comments.list.result' ) } 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) { // We need more attributes const userId: number = res.locals.oauth ? res.locals.oauth.token.User.id : null - const video = await Hooks.wrapPromise( - VideoModel.loadForGetAPI(res.locals.video.id, undefined, userId), + const video = await Hooks.wrapPromiseFun( + VideoModel.loadForGetAPI, + { id: res.locals.video.id, userId }, 'filter:api.video.get.result' ) @@ -502,8 +503,9 @@ async function listVideos (req: express.Request, res: express.Response) { user: res.locals.oauth ? res.locals.oauth.token.User : undefined }, 'filter:api.videos.list.params') - const resultList = await Hooks.wrapPromise( - VideoModel.listForApi(apiOptions), + const resultList = await Hooks.wrapPromiseFun( + VideoModel.listForApi, + apiOptions, 'filter:api.videos.list.result' ) -- cgit v1.2.3