diff options
author | Chocobozzz <me@florianbigard.com> | 2021-10-27 14:37:04 +0200 |
---|---|---|
committer | Chocobozzz <chocobozzz@cpy.re> | 2021-10-29 11:48:21 +0200 |
commit | 2760b454a761f6af3138b2fb5f34340772ab0d1e (patch) | |
tree | 2b3a2d81478f8b432eb54cce4caa5a760c494627 /server/controllers/api/search/search-videos.ts | |
parent | e4611b54910d8e7f2b4f8a97ee2d9cc8e1054127 (diff) | |
download | PeerTube-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.ts | 12 |
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' | |||
7 | import { getOrCreateAPVideo } from '@server/lib/activitypub/videos' | 7 | import { getOrCreateAPVideo } from '@server/lib/activitypub/videos' |
8 | import { Hooks } from '@server/lib/plugins/hooks' | 8 | import { Hooks } from '@server/lib/plugins/hooks' |
9 | import { buildMutedForSearchIndex, isSearchIndexSearch, isURISearch } from '@server/lib/search' | 9 | import { buildMutedForSearchIndex, isSearchIndexSearch, isURISearch } from '@server/lib/search' |
10 | import { getServerActor } from '@server/models/application/application' | ||
11 | import { guessAdditionalAttributesFromQuery } from '@server/models/video/formatter/video-format-utils' | ||
10 | import { HttpStatusCode, ResultList, Video } from '@shared/models' | 12 | import { HttpStatusCode, ResultList, Video } from '@shared/models' |
11 | import { VideosSearchQueryAfterSanitize } from '../../../../shared/models/search' | 13 | import { VideosSearchQueryAfterSanitize } from '../../../../shared/models/search' |
12 | import { buildNSFWFilter, isUserAbleToSearchRemoteURI } from '../../../helpers/express-utils' | 14 | import { buildNSFWFilter, isUserAbleToSearchRemoteURI } from '../../../helpers/express-utils' |
@@ -100,11 +102,15 @@ async function searchVideosIndex (query: VideosSearchQueryAfterSanitize, res: ex | |||
100 | } | 102 | } |
101 | 103 | ||
102 | async function searchVideosDB (query: VideosSearchQueryAfterSanitize, res: express.Response) { | 104 | async 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 | ||
124 | async function searchVideoURI (url: string, res: express.Response) { | 130 | async function searchVideoURI (url: string, res: express.Response) { |