diff options
Diffstat (limited to 'server/controllers/api/overviews.ts')
-rw-r--r-- | server/controllers/api/overviews.ts | 13 |
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 @@ | |||
1 | import * as express from 'express' | 1 | import * as express from 'express' |
2 | import * as memoizee from 'memoizee' | 2 | import * as memoizee from 'memoizee' |
3 | import { logger } from '@server/helpers/logger' | 3 | import { logger } from '@server/helpers/logger' |
4 | import { Hooks } from '@server/lib/plugins/hooks' | ||
5 | import { VideoModel } from '@server/models/video/video' | ||
4 | import { CategoryOverview, ChannelOverview, TagOverview, VideosOverview } from '../../../shared/models/overviews' | 6 | import { CategoryOverview, ChannelOverview, TagOverview, VideosOverview } from '../../../shared/models/overviews' |
5 | import { buildNSFWFilter } from '../../helpers/express-utils' | 7 | import { buildNSFWFilter } from '../../helpers/express-utils' |
6 | import { MEMOIZE_TTL, OVERVIEWS } from '../../initializers/constants' | 8 | import { MEMOIZE_TTL, OVERVIEWS } from '../../initializers/constants' |
7 | import { asyncMiddleware, optionalAuthenticate, videosOverviewValidator } from '../../middlewares' | 9 | import { asyncMiddleware, optionalAuthenticate, videosOverviewValidator } from '../../middlewares' |
8 | import { TagModel } from '../../models/video/tag' | 10 | import { TagModel } from '../../models/video/tag' |
9 | import { VideoModel } from '../../models/video/video' | ||
10 | 11 | ||
11 | const overviewsRouter = express.Router() | 12 | const 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 | } |