diff options
author | Chocobozzz <me@florianbigard.com> | 2018-02-15 14:46:26 +0100 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2018-02-15 15:29:07 +0100 |
commit | 2422c46b27790d94fd29a7092170cee5a1b56008 (patch) | |
tree | d5c1942ce20cadb27a551d87c789edfe92f5b105 /server/helpers | |
parent | 34cbef8c6cc912143a421413bdd832c4adcc556a (diff) | |
download | PeerTube-2422c46b27790d94fd29a7092170cee5a1b56008.tar.gz PeerTube-2422c46b27790d94fd29a7092170cee5a1b56008.tar.zst PeerTube-2422c46b27790d94fd29a7092170cee5a1b56008.zip |
Implement support field in video and video channel
Diffstat (limited to 'server/helpers')
-rw-r--r-- | server/helpers/activitypub.ts | 3 | ||||
-rw-r--r-- | server/helpers/custom-validators/accounts.ts | 7 | ||||
-rw-r--r-- | server/helpers/custom-validators/users.ts | 5 | ||||
-rw-r--r-- | server/helpers/custom-validators/video-channels.ts | 5 | ||||
-rw-r--r-- | server/helpers/custom-validators/videos.ts | 7 |
5 files changed, 24 insertions, 3 deletions
diff --git a/server/helpers/activitypub.ts b/server/helpers/activitypub.ts index eaee324eb..d64a6dd78 100644 --- a/server/helpers/activitypub.ts +++ b/server/helpers/activitypub.ts | |||
@@ -19,7 +19,8 @@ function activityPubContextify <T> (data: T) { | |||
19 | 'language': 'http://schema.org/inLanguage', | 19 | 'language': 'http://schema.org/inLanguage', |
20 | 'views': 'http://schema.org/Number', | 20 | 'views': 'http://schema.org/Number', |
21 | 'size': 'http://schema.org/Number', | 21 | 'size': 'http://schema.org/Number', |
22 | 'commentsEnabled': 'http://schema.org/Boolean' | 22 | 'commentsEnabled': 'http://schema.org/Boolean', |
23 | 'support': 'http://schema.org/Text' | ||
23 | }, | 24 | }, |
24 | { | 25 | { |
25 | likes: { | 26 | likes: { |
diff --git a/server/helpers/custom-validators/accounts.ts b/server/helpers/custom-validators/accounts.ts index 8dc5d1f0d..a46ffc162 100644 --- a/server/helpers/custom-validators/accounts.ts +++ b/server/helpers/custom-validators/accounts.ts | |||
@@ -3,12 +3,16 @@ import { Response } from 'express' | |||
3 | import 'express-validator' | 3 | import 'express-validator' |
4 | import * as validator from 'validator' | 4 | import * as validator from 'validator' |
5 | import { AccountModel } from '../../models/account/account' | 5 | import { AccountModel } from '../../models/account/account' |
6 | import { isUserUsernameValid } from './users' | 6 | import { isUserDescriptionValid, isUserUsernameValid } from './users' |
7 | 7 | ||
8 | function isAccountNameValid (value: string) { | 8 | function isAccountNameValid (value: string) { |
9 | return isUserUsernameValid(value) | 9 | return isUserUsernameValid(value) |
10 | } | 10 | } |
11 | 11 | ||
12 | function isAccountDescriptionValid (value: string) { | ||
13 | return isUserDescriptionValid(value) | ||
14 | } | ||
15 | |||
12 | function isAccountIdExist (id: number | string, res: Response) { | 16 | function isAccountIdExist (id: number | string, res: Response) { |
13 | let promise: Bluebird<AccountModel> | 17 | let promise: Bluebird<AccountModel> |
14 | 18 | ||
@@ -48,5 +52,6 @@ async function isAccountExist (p: Bluebird<AccountModel>, res: Response) { | |||
48 | export { | 52 | export { |
49 | isAccountIdExist, | 53 | isAccountIdExist, |
50 | isLocalAccountNameExist, | 54 | isLocalAccountNameExist, |
55 | isAccountDescriptionValid, | ||
51 | isAccountNameValid | 56 | isAccountNameValid |
52 | } | 57 | } |
diff --git a/server/helpers/custom-validators/users.ts b/server/helpers/custom-validators/users.ts index e805313f8..bbc7cc199 100644 --- a/server/helpers/custom-validators/users.ts +++ b/server/helpers/custom-validators/users.ts | |||
@@ -21,6 +21,10 @@ function isUserUsernameValid (value: string) { | |||
21 | return exists(value) && validator.matches(value, new RegExp(`^[a-z0-9._]{${min},${max}}$`)) | 21 | return exists(value) && validator.matches(value, new RegExp(`^[a-z0-9._]{${min},${max}}$`)) |
22 | } | 22 | } |
23 | 23 | ||
24 | function isUserDescriptionValid (value: string) { | ||
25 | return value === null || (exists(value) && validator.isLength(value, CONSTRAINTS_FIELDS.USERS.DESCRIPTION)) | ||
26 | } | ||
27 | |||
24 | function isBoolean (value: any) { | 28 | function isBoolean (value: any) { |
25 | return typeof value === 'boolean' || (typeof value === 'string' && validator.isBoolean(value)) | 29 | return typeof value === 'boolean' || (typeof value === 'string' && validator.isBoolean(value)) |
26 | } | 30 | } |
@@ -54,5 +58,6 @@ export { | |||
54 | isUserUsernameValid, | 58 | isUserUsernameValid, |
55 | isUserDisplayNSFWValid, | 59 | isUserDisplayNSFWValid, |
56 | isUserAutoPlayVideoValid, | 60 | isUserAutoPlayVideoValid, |
61 | isUserDescriptionValid, | ||
57 | isAvatarFile | 62 | isAvatarFile |
58 | } | 63 | } |
diff --git a/server/helpers/custom-validators/video-channels.ts b/server/helpers/custom-validators/video-channels.ts index 6bc96bf51..2a6f56840 100644 --- a/server/helpers/custom-validators/video-channels.ts +++ b/server/helpers/custom-validators/video-channels.ts | |||
@@ -16,6 +16,10 @@ function isVideoChannelNameValid (value: string) { | |||
16 | return exists(value) && validator.isLength(value, VIDEO_CHANNELS_CONSTRAINTS_FIELDS.NAME) | 16 | return exists(value) && validator.isLength(value, VIDEO_CHANNELS_CONSTRAINTS_FIELDS.NAME) |
17 | } | 17 | } |
18 | 18 | ||
19 | function isVideoChannelSupportValid (value: string) { | ||
20 | return value === null || (exists(value) && validator.isLength(value, VIDEO_CHANNELS_CONSTRAINTS_FIELDS.SUPPORT)) | ||
21 | } | ||
22 | |||
19 | async function isVideoChannelExist (id: string, res: express.Response) { | 23 | async function isVideoChannelExist (id: string, res: express.Response) { |
20 | let videoChannel: VideoChannelModel | 24 | let videoChannel: VideoChannelModel |
21 | if (validator.isInt(id)) { | 25 | if (validator.isInt(id)) { |
@@ -41,5 +45,6 @@ async function isVideoChannelExist (id: string, res: express.Response) { | |||
41 | export { | 45 | export { |
42 | isVideoChannelDescriptionValid, | 46 | isVideoChannelDescriptionValid, |
43 | isVideoChannelNameValid, | 47 | isVideoChannelNameValid, |
48 | isVideoChannelSupportValid, | ||
44 | isVideoChannelExist | 49 | isVideoChannelExist |
45 | } | 50 | } |
diff --git a/server/helpers/custom-validators/videos.ts b/server/helpers/custom-validators/videos.ts index 8ef3a3c64..a46d715ba 100644 --- a/server/helpers/custom-validators/videos.ts +++ b/server/helpers/custom-validators/videos.ts | |||
@@ -42,6 +42,10 @@ function isVideoDescriptionValid (value: string) { | |||
42 | return value === null || (exists(value) && validator.isLength(value, VIDEOS_CONSTRAINTS_FIELDS.DESCRIPTION)) | 42 | return value === null || (exists(value) && validator.isLength(value, VIDEOS_CONSTRAINTS_FIELDS.DESCRIPTION)) |
43 | } | 43 | } |
44 | 44 | ||
45 | function isVideoSupportValid (value: string) { | ||
46 | return value === null || (exists(value) && validator.isLength(value, VIDEOS_CONSTRAINTS_FIELDS.SUPPORT)) | ||
47 | } | ||
48 | |||
45 | function isVideoNameValid (value: string) { | 49 | function isVideoNameValid (value: string) { |
46 | return exists(value) && validator.isLength(value, VIDEOS_CONSTRAINTS_FIELDS.NAME) | 50 | return exists(value) && validator.isLength(value, VIDEOS_CONSTRAINTS_FIELDS.NAME) |
47 | } | 51 | } |
@@ -140,5 +144,6 @@ export { | |||
140 | isVideoFileResolutionValid, | 144 | isVideoFileResolutionValid, |
141 | isVideoFileSizeValid, | 145 | isVideoFileSizeValid, |
142 | isVideoExist, | 146 | isVideoExist, |
143 | isVideoImage | 147 | isVideoImage, |
148 | isVideoSupportValid | ||
144 | } | 149 | } |