import * as express from 'express'
import { sanitizeUrl } from '@server/helpers/core-utils'
-import { doRequest } from '@server/helpers/requests'
+import { doJSONRequest } from '@server/helpers/requests'
import { CONFIG } from '@server/initializers/config'
import { getOrCreateVideoAndAccountAndChannel } from '@server/lib/activitypub/videos'
import { AccountBlocklistModel } from '@server/models/account/account-blocklist'
}
async function searchVideoChannelsIndex (query: VideoChannelsSearchQuery, res: express.Response) {
- logger.debug('Doing channels search on search index.')
-
const result = await buildMutedForSearchIndex(res)
const body = Object.assign(query, result)
const url = sanitizeUrl(CONFIG.SEARCH.SEARCH_INDEX.URL) + '/api/v1/search/video-channels'
try {
- const searchIndexResult = await doRequest<ResultList<VideoChannel>>({ uri: url, body, json: true })
+ logger.debug('Doing video channels search index request on %s.', url, { body })
+
+ const { body: searchIndexResult } = await doJSONRequest<ResultList<VideoChannel>>(url, { method: 'POST', json: body })
- return res.json(searchIndexResult.body)
+ return res.json(searchIndexResult)
} catch (err) {
logger.warn('Cannot use search index to make video channels search.', { err })
}
async function searchVideosIndex (query: VideosSearchQuery, res: express.Response) {
- logger.debug('Doing videos search on search index.')
-
const result = await buildMutedForSearchIndex(res)
const body: VideosSearchQuery = Object.assign(query, result)
const url = sanitizeUrl(CONFIG.SEARCH.SEARCH_INDEX.URL) + '/api/v1/search/videos'
try {
- const searchIndexResult = await doRequest<ResultList<Video>>({ uri: url, body, json: true })
+ logger.debug('Doing videos search index request on %s.', url, { body })
+
+ const { body: searchIndexResult } = await doJSONRequest<ResultList<Video>>(url, { method: 'POST', json: body })
- return res.json(searchIndexResult.body)
+ return res.json(searchIndexResult)
} catch (err) {
logger.warn('Cannot use search index to make video search.', { err })