diff options
author | Chocobozzz <me@florianbigard.com> | 2021-07-29 11:54:38 +0200 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2021-07-29 11:54:38 +0200 |
commit | d6886027109af42be2e3ec5d14ad166199add11d (patch) | |
tree | 3a7603d36ff35a2d623d863f14ab93a2e1e6b7f2 /server/controllers/api/videos | |
parent | b033851fb54241bb703f86add025229e68cc6f59 (diff) | |
download | PeerTube-d6886027109af42be2e3ec5d14ad166199add11d.tar.gz PeerTube-d6886027109af42be2e3ec5d14ad166199add11d.tar.zst PeerTube-d6886027109af42be2e3ec5d14ad166199add11d.zip |
Refactor search query options
Diffstat (limited to 'server/controllers/api/videos')
-rw-r--r-- | server/controllers/api/videos/index.ts | 16 |
1 files changed, 4 insertions, 12 deletions
diff --git a/server/controllers/api/videos/index.ts b/server/controllers/api/videos/index.ts index 5a2ff81dc..49490f79b 100644 --- a/server/controllers/api/videos/index.ts +++ b/server/controllers/api/videos/index.ts | |||
@@ -1,11 +1,11 @@ | |||
1 | import * as express from 'express' | 1 | import * as express from 'express' |
2 | import toInt from 'validator/lib/toInt' | 2 | import toInt from 'validator/lib/toInt' |
3 | import { pickCommonVideoQuery } from '@server/helpers/query' | ||
3 | import { doJSONRequest } from '@server/helpers/requests' | 4 | import { doJSONRequest } from '@server/helpers/requests' |
4 | import { LiveManager } from '@server/lib/live' | 5 | import { LiveManager } from '@server/lib/live' |
5 | import { openapiOperationDoc } from '@server/middlewares/doc' | 6 | import { openapiOperationDoc } from '@server/middlewares/doc' |
6 | import { getServerActor } from '@server/models/application/application' | 7 | import { getServerActor } from '@server/models/application/application' |
7 | import { MVideoAccountLight } from '@server/types/models' | 8 | import { MVideoAccountLight } from '@server/types/models' |
8 | import { VideosCommonQuery } from '../../../../shared' | ||
9 | import { HttpStatusCode } from '../../../../shared/models' | 9 | import { HttpStatusCode } from '../../../../shared/models' |
10 | import { auditLoggerFactory, getAuditIdFromRes, VideoAuditView } from '../../../helpers/audit-logger' | 10 | import { auditLoggerFactory, getAuditIdFromRes, VideoAuditView } from '../../../helpers/audit-logger' |
11 | import { buildNSFWFilter, getCountVideos } from '../../../helpers/express-utils' | 11 | import { buildNSFWFilter, getCountVideos } from '../../../helpers/express-utils' |
@@ -211,22 +211,14 @@ async function getVideoFileMetadata (req: express.Request, res: express.Response | |||
211 | } | 211 | } |
212 | 212 | ||
213 | async function listVideos (req: express.Request, res: express.Response) { | 213 | async function listVideos (req: express.Request, res: express.Response) { |
214 | const query = req.query as VideosCommonQuery | 214 | const query = pickCommonVideoQuery(req.query) |
215 | const countVideos = getCountVideos(req) | 215 | const countVideos = getCountVideos(req) |
216 | 216 | ||
217 | const apiOptions = await Hooks.wrapObject({ | 217 | const apiOptions = await Hooks.wrapObject({ |
218 | start: query.start, | 218 | ...query, |
219 | count: query.count, | 219 | |
220 | sort: query.sort, | ||
221 | includeLocalVideos: true, | 220 | includeLocalVideos: true, |
222 | categoryOneOf: query.categoryOneOf, | ||
223 | licenceOneOf: query.licenceOneOf, | ||
224 | languageOneOf: query.languageOneOf, | ||
225 | tagsOneOf: query.tagsOneOf, | ||
226 | tagsAllOf: query.tagsAllOf, | ||
227 | nsfw: buildNSFWFilter(res, query.nsfw), | 221 | nsfw: buildNSFWFilter(res, query.nsfw), |
228 | isLive: query.isLive, | ||
229 | filter: query.filter, | ||
230 | withFiles: false, | 222 | withFiles: false, |
231 | user: res.locals.oauth ? res.locals.oauth.token.User : undefined, | 223 | user: res.locals.oauth ? res.locals.oauth.token.User : undefined, |
232 | countVideos | 224 | countVideos |