diff options
-rw-r--r-- | config/default.yaml | 4 | ||||
-rw-r--r-- | server/helpers/custom-validators/search.ts | 2 | ||||
-rw-r--r-- | server/lib/search.ts | 1 | ||||
-rw-r--r-- | server/tests/api/check-params/search.ts | 5 | ||||
-rw-r--r-- | server/tests/api/search/search-index.ts | 22 |
5 files changed, 3 insertions, 31 deletions
diff --git a/config/default.yaml b/config/default.yaml index 19e2fcf3a..1b7c3314d 100644 --- a/config/default.yaml +++ b/config/default.yaml | |||
@@ -730,9 +730,9 @@ search: | |||
730 | # You should deploy your own with https://framagit.org/framasoft/peertube/search-index, | 730 | # You should deploy your own with https://framagit.org/framasoft/peertube/search-index, |
731 | # and can use https://search.joinpeertube.org/ for tests, but keep in mind the latter is an unmoderated search index | 731 | # and can use https://search.joinpeertube.org/ for tests, but keep in mind the latter is an unmoderated search index |
732 | url: '' | 732 | url: '' |
733 | # You can disable local search, so users only use the search index | 733 | # You can disable local search in the client, so users only use the search index |
734 | disable_local_search: false | 734 | disable_local_search: false |
735 | # If you did not disable local search, you can decide to use the search index by default | 735 | # If you did not disable local search in the client, you can decide to use the search index by default |
736 | is_default_search: false | 736 | is_default_search: false |
737 | 737 | ||
738 | # PeerTube client/interface configuration | 738 | # PeerTube client/interface configuration |
diff --git a/server/helpers/custom-validators/search.ts b/server/helpers/custom-validators/search.ts index a8f258838..6dba5d14e 100644 --- a/server/helpers/custom-validators/search.ts +++ b/server/helpers/custom-validators/search.ts | |||
@@ -20,7 +20,7 @@ function isSearchTargetValid (value: SearchTargetType) { | |||
20 | 20 | ||
21 | const searchIndexConfig = CONFIG.SEARCH.SEARCH_INDEX | 21 | const searchIndexConfig = CONFIG.SEARCH.SEARCH_INDEX |
22 | 22 | ||
23 | if (value === 'local' && (!searchIndexConfig.ENABLED || !searchIndexConfig.DISABLE_LOCAL_SEARCH)) return true | 23 | if (value === 'local') return true |
24 | 24 | ||
25 | if (value === 'search-index' && searchIndexConfig.ENABLED) return true | 25 | if (value === 'search-index' && searchIndexConfig.ENABLED) return true |
26 | 26 | ||
diff --git a/server/lib/search.ts b/server/lib/search.ts index 2f4c5eed9..b3363fbec 100644 --- a/server/lib/search.ts +++ b/server/lib/search.ts | |||
@@ -12,7 +12,6 @@ function isSearchIndexSearch (query: SearchTargetQuery) { | |||
12 | 12 | ||
13 | if (searchIndexConfig.ENABLED !== true) return false | 13 | if (searchIndexConfig.ENABLED !== true) return false |
14 | 14 | ||
15 | if (searchIndexConfig.DISABLE_LOCAL_SEARCH) return true | ||
16 | if (searchIndexConfig.IS_DEFAULT_SEARCH && !query.searchTarget) return true | 15 | if (searchIndexConfig.IS_DEFAULT_SEARCH && !query.searchTarget) return true |
17 | 16 | ||
18 | return false | 17 | return false |
diff --git a/server/tests/api/check-params/search.ts b/server/tests/api/check-params/search.ts index 91e9122a7..72c25ba33 100644 --- a/server/tests/api/check-params/search.ts +++ b/server/tests/api/check-params/search.ts | |||
@@ -252,11 +252,6 @@ describe('Test videos API validator', function () { | |||
252 | await updateSearchIndex(server, true, true) | 252 | await updateSearchIndex(server, true, true) |
253 | 253 | ||
254 | { | 254 | { |
255 | const customQuery = { ...query, searchTarget: 'local' } | ||
256 | await makeGetRequest({ url: server.url, path, query: customQuery, expectedStatus: HttpStatusCode.BAD_REQUEST_400 }) | ||
257 | } | ||
258 | |||
259 | { | ||
260 | const customQuery = { ...query, searchTarget: 'search-index' } | 255 | const customQuery = { ...query, searchTarget: 'search-index' } |
261 | await makeGetRequest({ url: server.url, path, query: customQuery, expectedStatus: HttpStatusCode.OK_200 }) | 256 | await makeGetRequest({ url: server.url, path, query: customQuery, expectedStatus: HttpStatusCode.OK_200 }) |
262 | } | 257 | } |
diff --git a/server/tests/api/search/search-index.ts b/server/tests/api/search/search-index.ts index c61ac441d..eae4391ec 100644 --- a/server/tests/api/search/search-index.ts +++ b/server/tests/api/search/search-index.ts | |||
@@ -81,28 +81,6 @@ describe('Test index search', function () { | |||
81 | const body = await command.searchChannels({ search: 'root' }) | 81 | const body = await command.searchChannels({ search: 'root' }) |
82 | expect(body.total).to.be.greaterThan(2) | 82 | expect(body.total).to.be.greaterThan(2) |
83 | }) | 83 | }) |
84 | |||
85 | it('Should make an index videos search if local search is disabled', async function () { | ||
86 | await server.config.updateCustomSubConfig({ | ||
87 | newConfig: { | ||
88 | search: { | ||
89 | searchIndex: { | ||
90 | enabled: true, | ||
91 | isDefaultSearch: false, | ||
92 | disableLocalSearch: true | ||
93 | } | ||
94 | } | ||
95 | } | ||
96 | }) | ||
97 | |||
98 | const body = await command.searchVideos({ search: 'local video' }) | ||
99 | expect(body.total).to.be.greaterThan(2) | ||
100 | }) | ||
101 | |||
102 | it('Should make an index channels search if local search is disabled', async function () { | ||
103 | const body = await command.searchChannels({ search: 'root' }) | ||
104 | expect(body.total).to.be.greaterThan(2) | ||
105 | }) | ||
106 | }) | 84 | }) |
107 | 85 | ||
108 | describe('Videos search', async function () { | 86 | describe('Videos search', async function () { |