aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/controllers/api/accounts.ts
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2021-07-29 11:54:38 +0200
committerChocobozzz <me@florianbigard.com>2021-07-29 11:54:38 +0200
commitd6886027109af42be2e3ec5d14ad166199add11d (patch)
tree3a7603d36ff35a2d623d863f14ab93a2e1e6b7f2 /server/controllers/api/accounts.ts
parentb033851fb54241bb703f86add025229e68cc6f59 (diff)
downloadPeerTube-d6886027109af42be2e3ec5d14ad166199add11d.tar.gz
PeerTube-d6886027109af42be2e3ec5d14ad166199add11d.tar.zst
PeerTube-d6886027109af42be2e3ec5d14ad166199add11d.zip
Refactor search query options
Diffstat (limited to 'server/controllers/api/accounts.ts')
-rw-r--r--server/controllers/api/accounts.ts20
1 files changed, 6 insertions, 14 deletions
diff --git a/server/controllers/api/accounts.ts b/server/controllers/api/accounts.ts
index 49a8e3195..55e2aaf62 100644
--- a/server/controllers/api/accounts.ts
+++ b/server/controllers/api/accounts.ts
@@ -1,6 +1,6 @@
1import * as express from 'express' 1import * as express from 'express'
2import { pickCommonVideoQuery } from '@server/helpers/query'
2import { getServerActor } from '@server/models/application/application' 3import { getServerActor } from '@server/models/application/application'
3import { VideosWithSearchCommonQuery } from '@shared/models'
4import { buildNSFWFilter, getCountVideos, isUserAbleToSearchRemoteURI } from '../../helpers/express-utils' 4import { buildNSFWFilter, getCountVideos, isUserAbleToSearchRemoteURI } from '../../helpers/express-utils'
5import { getFormattedObjects } from '../../helpers/utils' 5import { getFormattedObjects } from '../../helpers/utils'
6import { JobQueue } from '../../lib/job-queue' 6import { JobQueue } from '../../lib/job-queue'
@@ -159,27 +159,19 @@ async function listAccountVideos (req: express.Request, res: express.Response) {
159 const account = res.locals.account 159 const account = res.locals.account
160 const followerActorId = isUserAbleToSearchRemoteURI(res) ? null : undefined 160 const followerActorId = isUserAbleToSearchRemoteURI(res) ? null : undefined
161 const countVideos = getCountVideos(req) 161 const countVideos = getCountVideos(req)
162 const query = req.query as VideosWithSearchCommonQuery 162 const query = pickCommonVideoQuery(req.query)
163 163
164 const apiOptions = await Hooks.wrapObject({ 164 const apiOptions = await Hooks.wrapObject({
165 ...query,
166
165 followerActorId, 167 followerActorId,
166 start: query.start, 168 search: req.query.search,
167 count: query.count,
168 sort: query.sort,
169 includeLocalVideos: true, 169 includeLocalVideos: true,
170 categoryOneOf: query.categoryOneOf,
171 licenceOneOf: query.licenceOneOf,
172 languageOneOf: query.languageOneOf,
173 tagsOneOf: query.tagsOneOf,
174 tagsAllOf: query.tagsAllOf,
175 filter: query.filter,
176 isLive: query.isLive,
177 nsfw: buildNSFWFilter(res, query.nsfw), 170 nsfw: buildNSFWFilter(res, query.nsfw),
178 withFiles: false, 171 withFiles: false,
179 accountId: account.id, 172 accountId: account.id,
180 user: res.locals.oauth ? res.locals.oauth.token.User : undefined, 173 user: res.locals.oauth ? res.locals.oauth.token.User : undefined,
181 countVideos, 174 countVideos
182 search: query.search
183 }, 'filter:api.accounts.videos.list.params') 175 }, 'filter:api.accounts.videos.list.params')
184 176
185 const resultList = await Hooks.wrapPromiseFun( 177 const resultList = await Hooks.wrapPromiseFun(