From: Chocobozzz Date: Tue, 4 Sep 2018 09:19:19 +0000 (+0200) Subject: Fix nsfw filter X-Git-Tag: v1.0.0-beta.12~42 X-Git-Url: https://git.immae.eu/?a=commitdiff_plain;h=eb87f9a4a90ffbac43075567eb0ea90e7379c4b2;p=github%2FChocobozzz%2FPeerTube.git Fix nsfw filter --- diff --git a/server/helpers/express-utils.ts b/server/helpers/express-utils.ts index b715fb7d0..9cf8fbeac 100644 --- a/server/helpers/express-utils.ts +++ b/server/helpers/express-utils.ts @@ -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 diff --git a/server/tests/api/videos/index.ts b/server/tests/api/videos/index.ts index a328a49c1..bf58f9c79 100644 --- a/server/tests/api/videos/index.ts +++ b/server/tests/api/videos/index.ts @@ -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' diff --git a/server/tests/api/videos/video-nsfw.ts b/server/tests/api/videos/video-nsfw.ts index 891148b07..eab7a6991 100644 --- a/server/tests/api/videos/video-nsfw.ts +++ b/server/tests/api/videos/video-nsfw.ts @@ -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)