diff options
author | Chocobozzz <me@florianbigard.com> | 2018-07-20 18:31:49 +0200 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2018-07-24 14:04:05 +0200 |
commit | 0b18f4aa80df8868bf34605423c7a298dffbb2aa (patch) | |
tree | 25299da5d94fc73e88b21e87aeb2c156999c6fcd /server/helpers | |
parent | d525fc399a14a8b16eaad6d4c0bc0a9c4093c3c9 (diff) | |
download | PeerTube-0b18f4aa80df8868bf34605423c7a298dffbb2aa.tar.gz PeerTube-0b18f4aa80df8868bf34605423c7a298dffbb2aa.tar.zst PeerTube-0b18f4aa80df8868bf34605423c7a298dffbb2aa.zip |
Add advanced search in client
Diffstat (limited to 'server/helpers')
-rw-r--r-- | server/helpers/custom-validators/search.ts | 7 | ||||
-rw-r--r-- | server/helpers/express-utils.ts | 6 |
2 files changed, 10 insertions, 3 deletions
diff --git a/server/helpers/custom-validators/search.ts b/server/helpers/custom-validators/search.ts index 2fde39160..15b389a58 100644 --- a/server/helpers/custom-validators/search.ts +++ b/server/helpers/custom-validators/search.ts | |||
@@ -11,9 +11,14 @@ function isStringArray (value: any) { | |||
11 | return isArray(value) && value.every(v => typeof v === 'string') | 11 | return isArray(value) && value.every(v => typeof v === 'string') |
12 | } | 12 | } |
13 | 13 | ||
14 | function isNSFWQueryValid (value: any) { | ||
15 | return value === 'true' || value === 'false' || value === 'both' | ||
16 | } | ||
17 | |||
14 | // --------------------------------------------------------------------------- | 18 | // --------------------------------------------------------------------------- |
15 | 19 | ||
16 | export { | 20 | export { |
17 | isNumberArray, | 21 | isNumberArray, |
18 | isStringArray | 22 | isStringArray, |
23 | isNSFWQueryValid | ||
19 | } | 24 | } |
diff --git a/server/helpers/express-utils.ts b/server/helpers/express-utils.ts index 5bf1e1a5f..76440348f 100644 --- a/server/helpers/express-utils.ts +++ b/server/helpers/express-utils.ts | |||
@@ -5,8 +5,10 @@ import { logger } from './logger' | |||
5 | import { User } from '../../shared/models/users' | 5 | import { User } from '../../shared/models/users' |
6 | import { generateRandomString } from './utils' | 6 | import { generateRandomString } from './utils' |
7 | 7 | ||
8 | function buildNSFWFilter (res: express.Response, paramNSFW?: boolean) { | 8 | function buildNSFWFilter (res: express.Response, paramNSFW?: string) { |
9 | if (paramNSFW === true || paramNSFW === false) return paramNSFW | 9 | if (paramNSFW === 'true') return true |
10 | if (paramNSFW === 'false') return false | ||
11 | if (paramNSFW === 'both') return undefined | ||
10 | 12 | ||
11 | if (res.locals.oauth) { | 13 | if (res.locals.oauth) { |
12 | const user: User = res.locals.oauth.token.User | 14 | const user: User = res.locals.oauth.token.User |