aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/controllers/api/overviews.ts
diff options
context:
space:
mode:
Diffstat (limited to 'server/controllers/api/overviews.ts')
-rw-r--r--server/controllers/api/overviews.ts13
1 files changed, 10 insertions, 3 deletions
diff --git a/server/controllers/api/overviews.ts b/server/controllers/api/overviews.ts
index aaa341d54..727ed66d7 100644
--- a/server/controllers/api/overviews.ts
+++ b/server/controllers/api/overviews.ts
@@ -1,12 +1,13 @@
1import * as express from 'express' 1import * as express from 'express'
2import * as memoizee from 'memoizee' 2import * as memoizee from 'memoizee'
3import { logger } from '@server/helpers/logger' 3import { logger } from '@server/helpers/logger'
4import { Hooks } from '@server/lib/plugins/hooks'
5import { VideoModel } from '@server/models/video/video'
4import { CategoryOverview, ChannelOverview, TagOverview, VideosOverview } from '../../../shared/models/overviews' 6import { CategoryOverview, ChannelOverview, TagOverview, VideosOverview } from '../../../shared/models/overviews'
5import { buildNSFWFilter } from '../../helpers/express-utils' 7import { buildNSFWFilter } from '../../helpers/express-utils'
6import { MEMOIZE_TTL, OVERVIEWS } from '../../initializers/constants' 8import { MEMOIZE_TTL, OVERVIEWS } from '../../initializers/constants'
7import { asyncMiddleware, optionalAuthenticate, videosOverviewValidator } from '../../middlewares' 9import { asyncMiddleware, optionalAuthenticate, videosOverviewValidator } from '../../middlewares'
8import { TagModel } from '../../models/video/tag' 10import { TagModel } from '../../models/video/tag'
9import { VideoModel } from '../../models/video/video'
10 11
11const overviewsRouter = express.Router() 12const overviewsRouter = express.Router()
12 13
@@ -108,7 +109,7 @@ async function getVideos (
108 res: express.Response, 109 res: express.Response,
109 where: { videoChannelId?: number, tagsOneOf?: string[], categoryOneOf?: number[] } 110 where: { videoChannelId?: number, tagsOneOf?: string[], categoryOneOf?: number[] }
110) { 111) {
111 const query = Object.assign({ 112 let query = Object.assign({
112 start: 0, 113 start: 0,
113 count: 12, 114 count: 12,
114 sort: '-createdAt', 115 sort: '-createdAt',
@@ -119,7 +120,13 @@ async function getVideos (
119 countVideos: false 120 countVideos: false
120 }, where) 121 }, where)
121 122
122 const { data } = await VideoModel.listForApi(query) 123 query = await Hooks.wrapObject(query, 'filter:api.overviews.videos.list.params')
124
125 const { data } = await Hooks.wrapPromiseFun(
126 VideoModel.listForApi,
127 query,
128 'filter:api.overviews.videos.list.result'
129 )
123 130
124 return data.map(d => d.toFormattedJSON()) 131 return data.map(d => d.toFormattedJSON())
125} 132}