diff options
author | Chocobozzz <florian.bigard@gmail.com> | 2017-12-08 17:31:21 +0100 |
---|---|---|
committer | Chocobozzz <florian.bigard@gmail.com> | 2017-12-08 17:31:21 +0100 |
commit | f595d3947708114deeed4312cc5ffd285745b090 (patch) | |
tree | e2fef8fae4e9d9ee6039ea2ab53eb20d11002969 /server/helpers/custom-validators | |
parent | e600e1fea275c12f4420e23624804617e61a082c (diff) | |
download | PeerTube-f595d3947708114deeed4312cc5ffd285745b090.tar.gz PeerTube-f595d3947708114deeed4312cc5ffd285745b090.tar.zst PeerTube-f595d3947708114deeed4312cc5ffd285745b090.zip |
Finish admin design
Diffstat (limited to 'server/helpers/custom-validators')
-rw-r--r-- | server/helpers/custom-validators/activitypub/videos.ts | 6 | ||||
-rw-r--r-- | server/helpers/custom-validators/videos.ts | 9 |
2 files changed, 8 insertions, 7 deletions
diff --git a/server/helpers/custom-validators/activitypub/videos.ts b/server/helpers/custom-validators/activitypub/videos.ts index 12c672fd2..2ed2988f5 100644 --- a/server/helpers/custom-validators/activitypub/videos.ts +++ b/server/helpers/custom-validators/activitypub/videos.ts | |||
@@ -49,14 +49,14 @@ function isVideoTorrentObjectValid (video: any) { | |||
49 | isActivityPubVideoDurationValid(video.duration) && | 49 | isActivityPubVideoDurationValid(video.duration) && |
50 | isUUIDValid(video.uuid) && | 50 | isUUIDValid(video.uuid) && |
51 | setValidRemoteTags(video) && | 51 | setValidRemoteTags(video) && |
52 | isRemoteIdentifierValid(video.category) && | 52 | (!video.category || isRemoteIdentifierValid(video.category)) && |
53 | isRemoteIdentifierValid(video.licence) && | 53 | (!video.licence || isRemoteIdentifierValid(video.licence)) && |
54 | (!video.language || isRemoteIdentifierValid(video.language)) && | 54 | (!video.language || isRemoteIdentifierValid(video.language)) && |
55 | isVideoViewsValid(video.views) && | 55 | isVideoViewsValid(video.views) && |
56 | isVideoNSFWValid(video.nsfw) && | 56 | isVideoNSFWValid(video.nsfw) && |
57 | isDateValid(video.published) && | 57 | isDateValid(video.published) && |
58 | isDateValid(video.updated) && | 58 | isDateValid(video.updated) && |
59 | isRemoteVideoContentValid(video.mediaType, video.content) && | 59 | (!video.content || isRemoteVideoContentValid(video.mediaType, video.content)) && |
60 | isRemoteVideoIconValid(video.icon) && | 60 | isRemoteVideoIconValid(video.icon) && |
61 | setValidRemoteVideoUrls(video) && | 61 | setValidRemoteVideoUrls(video) && |
62 | video.url.length !== 0 | 62 | video.url.length !== 0 |
diff --git a/server/helpers/custom-validators/videos.ts b/server/helpers/custom-validators/videos.ts index f13178c54..4fc460699 100644 --- a/server/helpers/custom-validators/videos.ts +++ b/server/helpers/custom-validators/videos.ts | |||
@@ -9,16 +9,17 @@ import { VIDEO_PRIVACIES } from '../../initializers/constants' | |||
9 | import { database as db } from '../../initializers/database' | 9 | import { database as db } from '../../initializers/database' |
10 | import { VideoInstance } from '../../models/video/video-interface' | 10 | import { VideoInstance } from '../../models/video/video-interface' |
11 | import { exists, isArray } from './misc' | 11 | import { exists, isArray } from './misc' |
12 | import isInt = require('validator/lib/isInt') | ||
12 | 13 | ||
13 | const VIDEOS_CONSTRAINTS_FIELDS = CONSTRAINTS_FIELDS.VIDEOS | 14 | const VIDEOS_CONSTRAINTS_FIELDS = CONSTRAINTS_FIELDS.VIDEOS |
14 | const VIDEO_ABUSES_CONSTRAINTS_FIELDS = CONSTRAINTS_FIELDS.VIDEO_ABUSES | 15 | const VIDEO_ABUSES_CONSTRAINTS_FIELDS = CONSTRAINTS_FIELDS.VIDEO_ABUSES |
15 | 16 | ||
16 | function isVideoCategoryValid (value: number) { | 17 | function isVideoCategoryValid (value: number) { |
17 | return VIDEO_CATEGORIES[value] !== undefined | 18 | return value === null || VIDEO_CATEGORIES[value] !== undefined |
18 | } | 19 | } |
19 | 20 | ||
20 | function isVideoLicenceValid (value: number) { | 21 | function isVideoLicenceValid (value: number) { |
21 | return VIDEO_LICENCES[value] !== undefined | 22 | return value === null || VIDEO_LICENCES[value] !== undefined |
22 | } | 23 | } |
23 | 24 | ||
24 | function isVideoLanguageValid (value: number) { | 25 | function isVideoLanguageValid (value: number) { |
@@ -38,7 +39,7 @@ function isVideoTruncatedDescriptionValid (value: string) { | |||
38 | } | 39 | } |
39 | 40 | ||
40 | function isVideoDescriptionValid (value: string) { | 41 | function isVideoDescriptionValid (value: string) { |
41 | return exists(value) && validator.isLength(value, VIDEOS_CONSTRAINTS_FIELDS.DESCRIPTION) | 42 | return value === null || (exists(value) && validator.isLength(value, VIDEOS_CONSTRAINTS_FIELDS.DESCRIPTION)) |
42 | } | 43 | } |
43 | 44 | ||
44 | function isVideoNameValid (value: string) { | 45 | function isVideoNameValid (value: string) { |
@@ -84,7 +85,7 @@ function isVideoFile (files: { [ fieldname: string ]: Express.Multer.File[] } | | |||
84 | } | 85 | } |
85 | 86 | ||
86 | function isVideoPrivacyValid (value: string) { | 87 | function isVideoPrivacyValid (value: string) { |
87 | return VIDEO_PRIVACIES[value] !== undefined | 88 | return validator.isInt(value + '') && VIDEO_PRIVACIES[value] !== undefined |
88 | } | 89 | } |
89 | 90 | ||
90 | function isVideoFileInfoHashValid (value: string) { | 91 | function isVideoFileInfoHashValid (value: string) { |