aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/controllers/api/accounts.ts
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2021-10-27 14:37:04 +0200
committerChocobozzz <chocobozzz@cpy.re>2021-10-29 11:48:21 +0200
commit2760b454a761f6af3138b2fb5f34340772ab0d1e (patch)
tree2b3a2d81478f8b432eb54cce4caa5a760c494627 /server/controllers/api/accounts.ts
parente4611b54910d8e7f2b4f8a97ee2d9cc8e1054127 (diff)
downloadPeerTube-2760b454a761f6af3138b2fb5f34340772ab0d1e.tar.gz
PeerTube-2760b454a761f6af3138b2fb5f34340772ab0d1e.tar.zst
PeerTube-2760b454a761f6af3138b2fb5f34340772ab0d1e.zip
Deprecate filter video query
Introduce include and isLocal instead
Diffstat (limited to 'server/controllers/api/accounts.ts')
-rw-r--r--server/controllers/api/accounts.ts18
1 files changed, 13 insertions, 5 deletions
diff --git a/server/controllers/api/accounts.ts b/server/controllers/api/accounts.ts
index 8eb880d59..44edffe38 100644
--- a/server/controllers/api/accounts.ts
+++ b/server/controllers/api/accounts.ts
@@ -2,6 +2,7 @@ import express from 'express'
2import { pickCommonVideoQuery } from '@server/helpers/query' 2import { pickCommonVideoQuery } from '@server/helpers/query'
3import { ActorFollowModel } from '@server/models/actor/actor-follow' 3import { ActorFollowModel } from '@server/models/actor/actor-follow'
4import { getServerActor } from '@server/models/application/application' 4import { getServerActor } from '@server/models/application/application'
5import { guessAdditionalAttributesFromQuery } from '@server/models/video/formatter/video-format-utils'
5import { buildNSFWFilter, getCountVideos, isUserAbleToSearchRemoteURI } from '../../helpers/express-utils' 6import { buildNSFWFilter, getCountVideos, isUserAbleToSearchRemoteURI } from '../../helpers/express-utils'
6import { getFormattedObjects } from '../../helpers/utils' 7import { getFormattedObjects } from '../../helpers/utils'
7import { JobQueue } from '../../lib/job-queue' 8import { JobQueue } from '../../lib/job-queue'
@@ -169,17 +170,24 @@ async function listAccountPlaylists (req: express.Request, res: express.Response
169} 170}
170 171
171async function listAccountVideos (req: express.Request, res: express.Response) { 172async function listAccountVideos (req: express.Request, res: express.Response) {
173 const serverActor = await getServerActor()
174
172 const account = res.locals.account 175 const account = res.locals.account
173 const followerActorId = isUserAbleToSearchRemoteURI(res) ? null : undefined 176
177 const displayOnlyForFollower = isUserAbleToSearchRemoteURI(res)
178 ? null
179 : {
180 actorId: serverActor.id,
181 orLocalVideos: true
182 }
183
174 const countVideos = getCountVideos(req) 184 const countVideos = getCountVideos(req)
175 const query = pickCommonVideoQuery(req.query) 185 const query = pickCommonVideoQuery(req.query)
176 186
177 const apiOptions = await Hooks.wrapObject({ 187 const apiOptions = await Hooks.wrapObject({
178 ...query, 188 ...query,
179 189
180 followerActorId, 190 displayOnlyForFollower,
181 search: req.query.search,
182 includeLocalVideos: true,
183 nsfw: buildNSFWFilter(res, query.nsfw), 191 nsfw: buildNSFWFilter(res, query.nsfw),
184 withFiles: false, 192 withFiles: false,
185 accountId: account.id, 193 accountId: account.id,
@@ -193,7 +201,7 @@ async function listAccountVideos (req: express.Request, res: express.Response) {
193 'filter:api.accounts.videos.list.result' 201 'filter:api.accounts.videos.list.result'
194 ) 202 )
195 203
196 return res.json(getFormattedObjects(resultList.data, resultList.total)) 204 return res.json(getFormattedObjects(resultList.data, resultList.total, guessAdditionalAttributesFromQuery(query)))
197} 205}
198 206
199async function listAccountRatings (req: express.Request, res: express.Response) { 207async function listAccountRatings (req: express.Request, res: express.Response) {