diff options
Diffstat (limited to 'server/helpers')
-rw-r--r-- | server/helpers/custom-validators/videos.ts | 13 | ||||
-rw-r--r-- | server/helpers/database-utils.ts | 6 |
2 files changed, 16 insertions, 3 deletions
diff --git a/server/helpers/custom-validators/videos.ts b/server/helpers/custom-validators/videos.ts index 8496e679a..a227136ac 100644 --- a/server/helpers/custom-validators/videos.ts +++ b/server/helpers/custom-validators/videos.ts | |||
@@ -3,7 +3,7 @@ import 'express-validator' | |||
3 | import { values } from 'lodash' | 3 | import { values } from 'lodash' |
4 | import 'multer' | 4 | import 'multer' |
5 | import * as validator from 'validator' | 5 | import * as validator from 'validator' |
6 | import { UserRight, VideoRateType } from '../../../shared' | 6 | import { UserRight, VideoPrivacy, VideoRateType } from '../../../shared' |
7 | import { | 7 | import { |
8 | CONSTRAINTS_FIELDS, | 8 | CONSTRAINTS_FIELDS, |
9 | VIDEO_CATEGORIES, | 9 | VIDEO_CATEGORIES, |
@@ -98,10 +98,18 @@ function isVideoImage (files: { [ fieldname: string ]: Express.Multer.File[] } | | |||
98 | return isFileValid(files, videoImageTypesRegex, field, true) | 98 | return isFileValid(files, videoImageTypesRegex, field, true) |
99 | } | 99 | } |
100 | 100 | ||
101 | function isVideoPrivacyValid (value: string) { | 101 | function isVideoPrivacyValid (value: number) { |
102 | return validator.isInt(value + '') && VIDEO_PRIVACIES[ value ] !== undefined | 102 | return validator.isInt(value + '') && VIDEO_PRIVACIES[ value ] !== undefined |
103 | } | 103 | } |
104 | 104 | ||
105 | function isScheduleVideoUpdatePrivacyValid (value: number) { | ||
106 | return validator.isInt(value + '') && | ||
107 | ( | ||
108 | value === VideoPrivacy.UNLISTED || | ||
109 | value === VideoPrivacy.PUBLIC | ||
110 | ) | ||
111 | } | ||
112 | |||
105 | function isVideoFileInfoHashValid (value: string) { | 113 | function isVideoFileInfoHashValid (value: string) { |
106 | return exists(value) && validator.isLength(value, VIDEOS_CONSTRAINTS_FIELDS.INFO_HASH) | 114 | return exists(value) && validator.isLength(value, VIDEOS_CONSTRAINTS_FIELDS.INFO_HASH) |
107 | } | 115 | } |
@@ -174,6 +182,7 @@ export { | |||
174 | isVideoFileInfoHashValid, | 182 | isVideoFileInfoHashValid, |
175 | isVideoNameValid, | 183 | isVideoNameValid, |
176 | isVideoTagsValid, | 184 | isVideoTagsValid, |
185 | isScheduleVideoUpdatePrivacyValid, | ||
177 | isVideoAbuseReasonValid, | 186 | isVideoAbuseReasonValid, |
178 | isVideoFile, | 187 | isVideoFile, |
179 | isVideoStateValid, | 188 | isVideoStateValid, |
diff --git a/server/helpers/database-utils.ts b/server/helpers/database-utils.ts index 9b861a88c..ededa7901 100644 --- a/server/helpers/database-utils.ts +++ b/server/helpers/database-utils.ts | |||
@@ -22,11 +22,15 @@ function retryTransactionWrapper <T, A> ( | |||
22 | ): Promise<T> | 22 | ): Promise<T> |
23 | 23 | ||
24 | function retryTransactionWrapper <T> ( | 24 | function retryTransactionWrapper <T> ( |
25 | functionToRetry: () => Promise<T> | Bluebird<T> | ||
26 | ): Promise<T> | ||
27 | |||
28 | function retryTransactionWrapper <T> ( | ||
25 | functionToRetry: (...args: any[]) => Promise<T> | Bluebird<T>, | 29 | functionToRetry: (...args: any[]) => Promise<T> | Bluebird<T>, |
26 | ...args: any[] | 30 | ...args: any[] |
27 | ): Promise<T> { | 31 | ): Promise<T> { |
28 | return transactionRetryer<T>(callback => { | 32 | return transactionRetryer<T>(callback => { |
29 | functionToRetry.apply(this, args) | 33 | functionToRetry.apply(null, args) |
30 | .then((result: T) => callback(null, result)) | 34 | .then((result: T) => callback(null, result)) |
31 | .catch(err => callback(err)) | 35 | .catch(err => callback(err)) |
32 | }) | 36 | }) |