aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/helpers/express-utils.ts
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2018-07-20 14:35:18 +0200
committerChocobozzz <me@florianbigard.com>2018-07-24 14:04:05 +0200
commitd525fc399a14a8b16eaad6d4c0bc0a9c4093c3c9 (patch)
tree4305044c4a97bdf1275b241c63cb0e85151cfb6a /server/helpers/express-utils.ts
parent57c36b277e68b764dd34cb2e449f6e2ca3d1e9b6 (diff)
downloadPeerTube-d525fc399a14a8b16eaad6d4c0bc0a9c4093c3c9.tar.gz
PeerTube-d525fc399a14a8b16eaad6d4c0bc0a9c4093c3c9.tar.zst
PeerTube-d525fc399a14a8b16eaad6d4c0bc0a9c4093c3c9.zip
Add videos list filters
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