aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/helpers
diff options
context:
space:
mode:
Diffstat (limited to 'server/helpers')
-rw-r--r--server/helpers/custom-validators/videos.ts13
-rw-r--r--server/helpers/database-utils.ts6
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'
3import { values } from 'lodash' 3import { values } from 'lodash'
4import 'multer' 4import 'multer'
5import * as validator from 'validator' 5import * as validator from 'validator'
6import { UserRight, VideoRateType } from '../../../shared' 6import { UserRight, VideoPrivacy, VideoRateType } from '../../../shared'
7import { 7import {
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
101function isVideoPrivacyValid (value: string) { 101function 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
105function isScheduleVideoUpdatePrivacyValid (value: number) {
106 return validator.isInt(value + '') &&
107 (
108 value === VideoPrivacy.UNLISTED ||
109 value === VideoPrivacy.PUBLIC
110 )
111}
112
105function isVideoFileInfoHashValid (value: string) { 113function 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
24function retryTransactionWrapper <T> ( 24function retryTransactionWrapper <T> (
25 functionToRetry: () => Promise<T> | Bluebird<T>
26): Promise<T>
27
28function 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 })