mirror of https://github.com/Chocobozzz/PeerTube
Use default nsfw instance policy for search index
parent
5a61ffbb7c
commit
1a40132c67
|
@ -169,7 +169,14 @@ async function searchVideosIndex (query: VideosSearchQuery, res: express.Respons
|
||||||
|
|
||||||
const result = await buildMutedForSearchIndex(res)
|
const result = await buildMutedForSearchIndex(res)
|
||||||
|
|
||||||
const body = Object.assign(query, result)
|
const body: VideosSearchQuery = Object.assign(query, result)
|
||||||
|
|
||||||
|
// Use the default instance NSFW policy if not specified
|
||||||
|
if (!body.nsfw) {
|
||||||
|
body.nsfw = CONFIG.INSTANCE.DEFAULT_NSFW_POLICY === 'do_not_list'
|
||||||
|
? 'false'
|
||||||
|
: 'both'
|
||||||
|
}
|
||||||
|
|
||||||
const url = sanitizeUrl(CONFIG.SEARCH.SEARCH_INDEX.URL) + '/api/v1/search/videos'
|
const url = sanitizeUrl(CONFIG.SEARCH.SEARCH_INDEX.URL) + '/api/v1/search/videos'
|
||||||
|
|
||||||
|
|
|
@ -209,6 +209,37 @@ describe('Test videos search', function () {
|
||||||
expect(res.body.total).to.be.greaterThan(5)
|
expect(res.body.total).to.be.greaterThan(5)
|
||||||
expect(res.body.data).to.have.lengthOf(5)
|
expect(res.body.data).to.have.lengthOf(5)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
it('Should use the nsfw instance policy as default', async function () {
|
||||||
|
let nsfwUUID: string
|
||||||
|
|
||||||
|
{
|
||||||
|
await updateCustomSubConfig(server.url, server.accessToken, { instance: { defaultNSFWPolicy: 'display' } })
|
||||||
|
|
||||||
|
const res = await searchVideo(server.url, 'NSFW search index')
|
||||||
|
const video = res.body.data[0] as Video
|
||||||
|
|
||||||
|
expect(res.body.data).to.have.length.greaterThan(0)
|
||||||
|
expect(video.nsfw).to.be.true
|
||||||
|
|
||||||
|
nsfwUUID = video.uuid
|
||||||
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
await updateCustomSubConfig(server.url, server.accessToken, { instance: { defaultNSFWPolicy: 'do_not_list' } })
|
||||||
|
|
||||||
|
const res = await searchVideo(server.url, 'NSFW search index')
|
||||||
|
|
||||||
|
try {
|
||||||
|
expect(res.body.data).to.have.lengthOf(0)
|
||||||
|
} catch (err) {
|
||||||
|
//
|
||||||
|
const video = res.body.data[0] as Video
|
||||||
|
|
||||||
|
expect(video.uuid).not.equal(nsfwUUID)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
describe('Channels search', async function () {
|
describe('Channels search', async function () {
|
||||||
|
|
Loading…
Reference in New Issue