From 38267c0c8aa80f974a2c0b4c2bd33c8d8008ac94 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Tue, 8 Dec 2020 10:30:33 +0100 Subject: Use dedicated hooks for account/channel videos --- server/controllers/api/accounts.ts | 4 ++-- server/controllers/api/video-channel.ts | 11 +++++++++-- 2 files changed, 11 insertions(+), 4 deletions(-) (limited to 'server/controllers/api') diff --git a/server/controllers/api/accounts.ts b/server/controllers/api/accounts.ts index 9eb29d330..e807b4f44 100644 --- a/server/controllers/api/accounts.ts +++ b/server/controllers/api/accounts.ts @@ -176,12 +176,12 @@ async function listAccountVideos (req: express.Request, res: express.Response) { accountId: account.id, user: res.locals.oauth ? res.locals.oauth.token.User : undefined, countVideos - }, 'filter:api.videos.list.params') + }, 'filter:api.accounts.videos.list.params') const resultList = await Hooks.wrapPromiseFun( VideoModel.listForApi, apiOptions, - 'filter:api.videos.list.result' + 'filter:api.accounts.videos.list.result' ) return res.json(getFormattedObjects(resultList.data, resultList.total)) diff --git a/server/controllers/api/video-channel.ts b/server/controllers/api/video-channel.ts index 5c96950c5..c48e00232 100644 --- a/server/controllers/api/video-channel.ts +++ b/server/controllers/api/video-channel.ts @@ -1,4 +1,5 @@ import * as express from 'express' +import { Hooks } from '@server/lib/plugins/hooks' import { getServerActor } from '@server/models/application/application' import { MChannelAccountDefault } from '@server/types/models' import { VideoChannelCreate, VideoChannelUpdate } from '../../../shared' @@ -266,7 +267,7 @@ async function listVideoChannelVideos (req: express.Request, res: express.Respon const followerActorId = isUserAbleToSearchRemoteURI(res) ? null : undefined const countVideos = getCountVideos(req) - const resultList = await VideoModel.listForApi({ + const apiOptions = await Hooks.wrapObject({ followerActorId, start: req.query.start, count: req.query.count, @@ -283,7 +284,13 @@ async function listVideoChannelVideos (req: express.Request, res: express.Respon videoChannelId: videoChannelInstance.id, user: res.locals.oauth ? res.locals.oauth.token.User : undefined, countVideos - }) + }, 'filter:api.video-channels.videos.list.params') + + const resultList = await Hooks.wrapPromiseFun( + VideoModel.listForApi, + apiOptions, + 'filter:api.video-channels.videos.list.result' + ) return res.json(getFormattedObjects(resultList.data, resultList.total)) } -- cgit v1.2.3