Fix DISABLE_LOCAL_SEARCH blocking request to local search API (#5411)
This commit is contained in:
parent
77239b425a
commit
fbad149ff2
|
@ -730,9 +730,9 @@ search:
|
||||||
# You should deploy your own with https://framagit.org/framasoft/peertube/search-index,
|
# You should deploy your own with https://framagit.org/framasoft/peertube/search-index,
|
||||||
# and can use https://search.joinpeertube.org/ for tests, but keep in mind the latter is an unmoderated search index
|
# and can use https://search.joinpeertube.org/ for tests, but keep in mind the latter is an unmoderated search index
|
||||||
url: ''
|
url: ''
|
||||||
# You can disable local search, so users only use the search index
|
# You can disable local search in the client, so users only use the search index
|
||||||
disable_local_search: false
|
disable_local_search: false
|
||||||
# If you did not disable local search, you can decide to use the search index by default
|
# If you did not disable local search in the client, you can decide to use the search index by default
|
||||||
is_default_search: false
|
is_default_search: false
|
||||||
|
|
||||||
# PeerTube client/interface configuration
|
# PeerTube client/interface configuration
|
||||||
|
|
|
@ -20,7 +20,7 @@ function isSearchTargetValid (value: SearchTargetType) {
|
||||||
|
|
||||||
const searchIndexConfig = CONFIG.SEARCH.SEARCH_INDEX
|
const searchIndexConfig = CONFIG.SEARCH.SEARCH_INDEX
|
||||||
|
|
||||||
if (value === 'local' && (!searchIndexConfig.ENABLED || !searchIndexConfig.DISABLE_LOCAL_SEARCH)) return true
|
if (value === 'local') return true
|
||||||
|
|
||||||
if (value === 'search-index' && searchIndexConfig.ENABLED) return true
|
if (value === 'search-index' && searchIndexConfig.ENABLED) return true
|
||||||
|
|
||||||
|
|
|
@ -12,7 +12,6 @@ function isSearchIndexSearch (query: SearchTargetQuery) {
|
||||||
|
|
||||||
if (searchIndexConfig.ENABLED !== true) return false
|
if (searchIndexConfig.ENABLED !== true) return false
|
||||||
|
|
||||||
if (searchIndexConfig.DISABLE_LOCAL_SEARCH) return true
|
|
||||||
if (searchIndexConfig.IS_DEFAULT_SEARCH && !query.searchTarget) return true
|
if (searchIndexConfig.IS_DEFAULT_SEARCH && !query.searchTarget) return true
|
||||||
|
|
||||||
return false
|
return false
|
||||||
|
|
|
@ -251,11 +251,6 @@ describe('Test videos API validator', function () {
|
||||||
|
|
||||||
await updateSearchIndex(server, true, true)
|
await updateSearchIndex(server, true, true)
|
||||||
|
|
||||||
{
|
|
||||||
const customQuery = { ...query, searchTarget: 'local' }
|
|
||||||
await makeGetRequest({ url: server.url, path, query: customQuery, expectedStatus: HttpStatusCode.BAD_REQUEST_400 })
|
|
||||||
}
|
|
||||||
|
|
||||||
{
|
{
|
||||||
const customQuery = { ...query, searchTarget: 'search-index' }
|
const customQuery = { ...query, searchTarget: 'search-index' }
|
||||||
await makeGetRequest({ url: server.url, path, query: customQuery, expectedStatus: HttpStatusCode.OK_200 })
|
await makeGetRequest({ url: server.url, path, query: customQuery, expectedStatus: HttpStatusCode.OK_200 })
|
||||||
|
|
|
@ -81,28 +81,6 @@ describe('Test index search', function () {
|
||||||
const body = await command.searchChannels({ search: 'root' })
|
const body = await command.searchChannels({ search: 'root' })
|
||||||
expect(body.total).to.be.greaterThan(2)
|
expect(body.total).to.be.greaterThan(2)
|
||||||
})
|
})
|
||||||
|
|
||||||
it('Should make an index videos search if local search is disabled', async function () {
|
|
||||||
await server.config.updateCustomSubConfig({
|
|
||||||
newConfig: {
|
|
||||||
search: {
|
|
||||||
searchIndex: {
|
|
||||||
enabled: true,
|
|
||||||
isDefaultSearch: false,
|
|
||||||
disableLocalSearch: true
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
})
|
|
||||||
|
|
||||||
const body = await command.searchVideos({ search: 'local video' })
|
|
||||||
expect(body.total).to.be.greaterThan(2)
|
|
||||||
})
|
|
||||||
|
|
||||||
it('Should make an index channels search if local search is disabled', async function () {
|
|
||||||
const body = await command.searchChannels({ search: 'root' })
|
|
||||||
expect(body.total).to.be.greaterThan(2)
|
|
||||||
})
|
|
||||||
})
|
})
|
||||||
|
|
||||||
describe('Videos search', async function () {
|
describe('Videos search', async function () {
|
||||||
|
|
Loading…
Reference in New Issue
Block a user