aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/controllers/api/search/search-videos.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/search/search-videos.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/search/search-videos.ts')
-rw-r--r--server/controllers/api/search/search-videos.ts12
1 files changed, 9 insertions, 3 deletions
diff --git a/server/controllers/api/search/search-videos.ts b/server/controllers/api/search/search-videos.ts
index 90946cb74..6db70acdf 100644
--- a/server/controllers/api/search/search-videos.ts
+++ b/server/controllers/api/search/search-videos.ts
@@ -7,6 +7,8 @@ import { WEBSERVER } from '@server/initializers/constants'
7import { getOrCreateAPVideo } from '@server/lib/activitypub/videos' 7import { getOrCreateAPVideo } from '@server/lib/activitypub/videos'
8import { Hooks } from '@server/lib/plugins/hooks' 8import { Hooks } from '@server/lib/plugins/hooks'
9import { buildMutedForSearchIndex, isSearchIndexSearch, isURISearch } from '@server/lib/search' 9import { buildMutedForSearchIndex, isSearchIndexSearch, isURISearch } from '@server/lib/search'
10import { getServerActor } from '@server/models/application/application'
11import { guessAdditionalAttributesFromQuery } from '@server/models/video/formatter/video-format-utils'
10import { HttpStatusCode, ResultList, Video } from '@shared/models' 12import { HttpStatusCode, ResultList, Video } from '@shared/models'
11import { VideosSearchQueryAfterSanitize } from '../../../../shared/models/search' 13import { VideosSearchQueryAfterSanitize } from '../../../../shared/models/search'
12import { buildNSFWFilter, isUserAbleToSearchRemoteURI } from '../../../helpers/express-utils' 14import { buildNSFWFilter, isUserAbleToSearchRemoteURI } from '../../../helpers/express-utils'
@@ -100,11 +102,15 @@ async function searchVideosIndex (query: VideosSearchQueryAfterSanitize, res: ex
100} 102}
101 103
102async function searchVideosDB (query: VideosSearchQueryAfterSanitize, res: express.Response) { 104async function searchVideosDB (query: VideosSearchQueryAfterSanitize, res: express.Response) {
105 const serverActor = await getServerActor()
106
103 const apiOptions = await Hooks.wrapObject({ 107 const apiOptions = await Hooks.wrapObject({
104 ...query, 108 ...query,
105 109
106 includeLocalVideos: true, 110 displayOnlyForFollower: {
107 filter: query.filter, 111 actorId: serverActor.id,
112 orLocalVideos: true
113 },
108 114
109 nsfw: buildNSFWFilter(res, query.nsfw), 115 nsfw: buildNSFWFilter(res, query.nsfw),
110 user: res.locals.oauth 116 user: res.locals.oauth
@@ -118,7 +124,7 @@ async function searchVideosDB (query: VideosSearchQueryAfterSanitize, res: expre
118 'filter:api.search.videos.local.list.result' 124 'filter:api.search.videos.local.list.result'
119 ) 125 )
120 126
121 return res.json(getFormattedObjects(resultList.data, resultList.total)) 127 return res.json(getFormattedObjects(resultList.data, resultList.total, guessAdditionalAttributesFromQuery(query)))
122} 128}
123 129
124async function searchVideoURI (url: string, res: express.Response) { 130async function searchVideoURI (url: string, res: express.Response) {