1
0
Fork 0

Fix nsfw filter

This commit is contained in:
Chocobozzz 2018-09-04 11:19:19 +02:00
parent b0c36821d1
commit eb87f9a4a9
No known key found for this signature in database
GPG key ID: 583A612D890159BE
3 changed files with 9 additions and 2 deletions

View file

@ -14,8 +14,12 @@ function buildNSFWFilter (res: express.Response, paramNSFW?: string) {
if (res.locals.oauth) {
const user: User = res.locals.oauth.token.User
// User does not want NSFW videos
if (user && user.nsfwPolicy === 'do_not_list') return false
if (user.nsfwPolicy === 'do_not_list') return false
// Both
return undefined
}
if (CONFIG.INSTANCE.DEFAULT_NSFW_POLICY === 'do_not_list') return false

View file

@ -5,7 +5,7 @@ import './video-abuse'
import './video-blacklist'
import './video-blacklist-management'
import './video-captions'
import './vidoe-change-ownership'
import './video-change-ownership'
import './video-channels'
import './video-comments'
import './video-description'

View file

@ -148,6 +148,9 @@ describe('Test video NSFW policy', function () {
})
it('Should display NSFW videos with blur user NSFW policy', async function () {
customConfig.instance.defaultNSFWPolicy = 'do_not_list'
await updateCustomConfig(server.url, server.accessToken, customConfig)
for (const res of await getVideosFunctions(userAccessToken)) {
expect(res.body.total).to.equal(2)