Add hook filters tests

This commit is contained in:
Chocobozzz
2019-07-19 17:30:41 +02:00
committed by Chocobozzz
parent 09071200c7
commit 89cd127560
18 changed files with 306 additions and 80 deletions

View File

@@ -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)

View File

@@ -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 {

View File

@@ -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'
)