aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/controllers/api/search/search-video-channels.ts
diff options
context:
space:
mode:
Diffstat (limited to 'server/controllers/api/search/search-video-channels.ts')
-rw-r--r--server/controllers/api/search/search-video-channels.ts19
1 files changed, 8 insertions, 11 deletions
diff --git a/server/controllers/api/search/search-video-channels.ts b/server/controllers/api/search/search-video-channels.ts
index ae32a6726..eef222506 100644
--- a/server/controllers/api/search/search-video-channels.ts
+++ b/server/controllers/api/search/search-video-channels.ts
@@ -1,5 +1,6 @@
1import * as express from 'express' 1import * as express from 'express'
2import { sanitizeUrl } from '@server/helpers/core-utils' 2import { sanitizeUrl } from '@server/helpers/core-utils'
3import { pickSearchChannelQuery } from '@server/helpers/query'
3import { doJSONRequest } from '@server/helpers/requests' 4import { doJSONRequest } from '@server/helpers/requests'
4import { CONFIG } from '@server/initializers/config' 5import { CONFIG } from '@server/initializers/config'
5import { WEBSERVER } from '@server/initializers/constants' 6import { WEBSERVER } from '@server/initializers/constants'
@@ -7,7 +8,7 @@ import { Hooks } from '@server/lib/plugins/hooks'
7import { buildMutedForSearchIndex, isSearchIndexSearch, isURISearch } from '@server/lib/search' 8import { buildMutedForSearchIndex, isSearchIndexSearch, isURISearch } from '@server/lib/search'
8import { getServerActor } from '@server/models/application/application' 9import { getServerActor } from '@server/models/application/application'
9import { HttpStatusCode, ResultList, VideoChannel } from '@shared/models' 10import { HttpStatusCode, ResultList, VideoChannel } from '@shared/models'
10import { VideoChannelsSearchQuery } from '../../../../shared/models/search' 11import { VideoChannelsSearchQueryAfterSanitize } from '../../../../shared/models/search'
11import { isUserAbleToSearchRemoteURI } from '../../../helpers/express-utils' 12import { isUserAbleToSearchRemoteURI } from '../../../helpers/express-utils'
12import { logger } from '../../../helpers/logger' 13import { logger } from '../../../helpers/logger'
13import { getFormattedObjects } from '../../../helpers/utils' 14import { getFormattedObjects } from '../../../helpers/utils'
@@ -45,7 +46,7 @@ export { searchChannelsRouter }
45// --------------------------------------------------------------------------- 46// ---------------------------------------------------------------------------
46 47
47function searchVideoChannels (req: express.Request, res: express.Response) { 48function searchVideoChannels (req: express.Request, res: express.Response) {
48 const query: VideoChannelsSearchQuery = req.query 49 const query = pickSearchChannelQuery(req.query)
49 let search = query.search || '' 50 let search = query.search || ''
50 51
51 const parts = search.split('@') 52 const parts = search.split('@')
@@ -66,7 +67,7 @@ function searchVideoChannels (req: express.Request, res: express.Response) {
66 return searchVideoChannelsDB(query, res) 67 return searchVideoChannelsDB(query, res)
67} 68}
68 69
69async function searchVideoChannelsIndex (query: VideoChannelsSearchQuery, res: express.Response) { 70async function searchVideoChannelsIndex (query: VideoChannelsSearchQueryAfterSanitize, res: express.Response) {
70 const result = await buildMutedForSearchIndex(res) 71 const result = await buildMutedForSearchIndex(res)
71 72
72 const body = await Hooks.wrapObject(Object.assign(query, result), 'filter:api.search.video-channels.index.list.params') 73 const body = await Hooks.wrapObject(Object.assign(query, result), 'filter:api.search.video-channels.index.list.params')
@@ -90,17 +91,13 @@ async function searchVideoChannelsIndex (query: VideoChannelsSearchQuery, res: e
90 } 91 }
91} 92}
92 93
93async function searchVideoChannelsDB (query: VideoChannelsSearchQuery, res: express.Response) { 94async function searchVideoChannelsDB (query: VideoChannelsSearchQueryAfterSanitize, res: express.Response) {
94 const serverActor = await getServerActor() 95 const serverActor = await getServerActor()
95 96
96 const apiOptions = await Hooks.wrapObject({ 97 const apiOptions = await Hooks.wrapObject({
97 actorId: serverActor.id, 98 ...query,
98 search: query.search, 99
99 start: query.start, 100 actorId: serverActor.id
100 count: query.count,
101 sort: query.sort,
102 host: query.host,
103 handles: query.handles
104 }, 'filter:api.search.video-channels.local.list.params') 101 }, 'filter:api.search.video-channels.local.list.params')
105 102
106 const resultList = await Hooks.wrapPromiseFun( 103 const resultList = await Hooks.wrapPromiseFun(