aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/helpers/custom-validators
diff options
context:
space:
mode:
Diffstat (limited to 'server/helpers/custom-validators')
-rw-r--r--server/helpers/custom-validators/activitypub/videos.ts6
-rw-r--r--server/helpers/custom-validators/videos.ts8
2 files changed, 7 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..37fa8b08a 100644
--- a/server/helpers/custom-validators/videos.ts
+++ b/server/helpers/custom-validators/videos.ts
@@ -14,11 +14,11 @@ const VIDEOS_CONSTRAINTS_FIELDS = CONSTRAINTS_FIELDS.VIDEOS
14const VIDEO_ABUSES_CONSTRAINTS_FIELDS = CONSTRAINTS_FIELDS.VIDEO_ABUSES 14const VIDEO_ABUSES_CONSTRAINTS_FIELDS = CONSTRAINTS_FIELDS.VIDEO_ABUSES
15 15
16function isVideoCategoryValid (value: number) { 16function isVideoCategoryValid (value: number) {
17 return VIDEO_CATEGORIES[value] !== undefined 17 return value === null || VIDEO_CATEGORIES[value] !== undefined
18} 18}
19 19
20function isVideoLicenceValid (value: number) { 20function isVideoLicenceValid (value: number) {
21 return VIDEO_LICENCES[value] !== undefined 21 return value === null || VIDEO_LICENCES[value] !== undefined
22} 22}
23 23
24function isVideoLanguageValid (value: number) { 24function isVideoLanguageValid (value: number) {
@@ -38,7 +38,7 @@ function isVideoTruncatedDescriptionValid (value: string) {
38} 38}
39 39
40function isVideoDescriptionValid (value: string) { 40function isVideoDescriptionValid (value: string) {
41 return exists(value) && validator.isLength(value, VIDEOS_CONSTRAINTS_FIELDS.DESCRIPTION) 41 return value === null || (exists(value) && validator.isLength(value, VIDEOS_CONSTRAINTS_FIELDS.DESCRIPTION))
42} 42}
43 43
44function isVideoNameValid (value: string) { 44function isVideoNameValid (value: string) {
@@ -84,7 +84,7 @@ function isVideoFile (files: { [ fieldname: string ]: Express.Multer.File[] } |
84} 84}
85 85
86function isVideoPrivacyValid (value: string) { 86function isVideoPrivacyValid (value: string) {
87 return VIDEO_PRIVACIES[value] !== undefined 87 return validator.isInt(value + '') && VIDEO_PRIVACIES[value] !== undefined
88} 88}
89 89
90function isVideoFileInfoHashValid (value: string) { 90function isVideoFileInfoHashValid (value: string) {