aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/helpers/express-utils.ts
diff options
context:
space:
mode:
Diffstat (limited to 'server/helpers/express-utils.ts')
-rw-r--r--server/helpers/express-utils.ts14
1 files changed, 10 insertions, 4 deletions
diff --git a/server/helpers/express-utils.ts b/server/helpers/express-utils.ts
index d023117a8..5bf1e1a5f 100644
--- a/server/helpers/express-utils.ts
+++ b/server/helpers/express-utils.ts
@@ -5,13 +5,19 @@ import { logger } from './logger'
5import { User } from '../../shared/models/users' 5import { User } from '../../shared/models/users'
6import { generateRandomString } from './utils' 6import { generateRandomString } from './utils'
7 7
8function isNSFWHidden (res: express.Response) { 8function buildNSFWFilter (res: express.Response, paramNSFW?: boolean) {
9 if (paramNSFW === true || paramNSFW === false) return paramNSFW
10
9 if (res.locals.oauth) { 11 if (res.locals.oauth) {
10 const user: User = res.locals.oauth.token.User 12 const user: User = res.locals.oauth.token.User
11 if (user) return user.nsfwPolicy === 'do_not_list' 13 // User does not want NSFW videos
14 if (user && user.nsfwPolicy === 'do_not_list') return false
12 } 15 }
13 16
14 return CONFIG.INSTANCE.DEFAULT_NSFW_POLICY === 'do_not_list' 17 if (CONFIG.INSTANCE.DEFAULT_NSFW_POLICY === 'do_not_list') return false
18
19 // Display all
20 return null
15} 21}
16 22
17function getHostWithPort (host: string) { 23function getHostWithPort (host: string) {
@@ -70,7 +76,7 @@ function createReqFiles (
70// --------------------------------------------------------------------------- 76// ---------------------------------------------------------------------------
71 77
72export { 78export {
73 isNSFWHidden, 79 buildNSFWFilter,
74 getHostWithPort, 80 getHostWithPort,
75 badRequest, 81 badRequest,
76 createReqFiles 82 createReqFiles