aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/helpers
diff options
context:
space:
mode:
Diffstat (limited to 'server/helpers')
-rw-r--r--server/helpers/core-utils.ts2
-rw-r--r--server/helpers/custom-validators/misc.ts10
-rw-r--r--server/helpers/custom-validators/pods.ts23
-rw-r--r--server/helpers/custom-validators/remote/videos.ts12
-rw-r--r--server/helpers/custom-validators/users.ts14
-rw-r--r--server/helpers/custom-validators/videos.ts58
6 files changed, 60 insertions, 59 deletions
diff --git a/server/helpers/core-utils.ts b/server/helpers/core-utils.ts
index d28c97f09..f8dd45533 100644
--- a/server/helpers/core-utils.ts
+++ b/server/helpers/core-utils.ts
@@ -74,7 +74,7 @@ const readFilePromise = promisify2<string, string, string>(readFile)
74const readFileBufferPromise = promisify1<string, Buffer>(readFile) 74const readFileBufferPromise = promisify1<string, Buffer>(readFile)
75const unlinkPromise = promisify1WithVoid<string>(unlink) 75const unlinkPromise = promisify1WithVoid<string>(unlink)
76const renamePromise = promisify2WithVoid<string, string>(rename) 76const renamePromise = promisify2WithVoid<string, string>(rename)
77const writeFilePromise = promisify2<string, any, void>(writeFile) 77const writeFilePromise = promisify2WithVoid<string, any>(writeFile)
78const readdirPromise = promisify1<string, string[]>(readdir) 78const readdirPromise = promisify1<string, string[]>(readdir)
79const mkdirpPromise = promisify1<string, string>(mkdirp) 79const mkdirpPromise = promisify1<string, string>(mkdirp)
80const pseudoRandomBytesPromise = promisify1<number, Buffer>(pseudoRandomBytes) 80const pseudoRandomBytesPromise = promisify1<number, Buffer>(pseudoRandomBytes)
diff --git a/server/helpers/custom-validators/misc.ts b/server/helpers/custom-validators/misc.ts
index b1291ba7a..f6bb02c8e 100644
--- a/server/helpers/custom-validators/misc.ts
+++ b/server/helpers/custom-validators/misc.ts
@@ -13,11 +13,9 @@ export {
13 isArray 13 isArray
14} 14}
15 15
16declare global { 16declare module 'express-validator' {
17 namespace ExpressValidator { 17 export interface Validator {
18 export interface Validator { 18 exists,
19 exists, 19 isArray
20 isArray
21 }
22 } 20 }
23} 21}
diff --git a/server/helpers/custom-validators/pods.ts b/server/helpers/custom-validators/pods.ts
index 0519def52..f2ca520c0 100644
--- a/server/helpers/custom-validators/pods.ts
+++ b/server/helpers/custom-validators/pods.ts
@@ -1,9 +1,20 @@
1import * as validator from 'validator' 1import * as validator from 'validator'
2 2
3import { isArray, exists } from './misc' 3import { isArray, exists } from './misc'
4import { isTestInstance } from '../core-utils'
4 5
5function isHostValid (host: string) { 6function isHostValid (host: string) {
6 return exists(host) && validator.isURL(host) && host.split('://').length === 1 7 const isURLOptions = {
8 require_host: true,
9 require_tld: true
10 }
11
12 // We validate 'localhost', so we don't have the top level domain
13 if (isTestInstance()) {
14 isURLOptions.require_tld = false
15 }
16
17 return exists(host) && validator.isURL(host, isURLOptions) && host.split('://').length === 1
7} 18}
8 19
9function isEachUniqueHostValid (hosts: string[]) { 20function isEachUniqueHostValid (hosts: string[]) {
@@ -21,11 +32,9 @@ export {
21 isHostValid 32 isHostValid
22} 33}
23 34
24declare global { 35declare module 'express-validator' {
25 namespace ExpressValidator { 36 export interface Validator {
26 export interface Validator { 37 isEachUniqueHostValid
27 isEachUniqueHostValid 38 isHostValid
28 isHostValid
29 }
30 } 39 }
31} 40}
diff --git a/server/helpers/custom-validators/remote/videos.ts b/server/helpers/custom-validators/remote/videos.ts
index 091cd2186..49f76e909 100644
--- a/server/helpers/custom-validators/remote/videos.ts
+++ b/server/helpers/custom-validators/remote/videos.ts
@@ -101,13 +101,11 @@ export {
101 isEachRemoteRequestVideosEventsValid 101 isEachRemoteRequestVideosEventsValid
102} 102}
103 103
104declare global { 104declare module 'express-validator' {
105 namespace ExpressValidator { 105 export interface Validator {
106 export interface Validator { 106 isEachRemoteRequestVideosValid,
107 isEachRemoteRequestVideosValid, 107 isEachRemoteRequestVideosQaduValid,
108 isEachRemoteRequestVideosQaduValid, 108 isEachRemoteRequestVideosEventsValid
109 isEachRemoteRequestVideosEventsValid
110 }
111 } 109 }
112} 110}
113 111
diff --git a/server/helpers/custom-validators/users.ts b/server/helpers/custom-validators/users.ts
index 750563ada..2b37bdde8 100644
--- a/server/helpers/custom-validators/users.ts
+++ b/server/helpers/custom-validators/users.ts
@@ -34,13 +34,11 @@ export {
34 isUserDisplayNSFWValid 34 isUserDisplayNSFWValid
35} 35}
36 36
37declare global { 37declare module 'express-validator' {
38 namespace ExpressValidator { 38 export interface Validator {
39 export interface Validator { 39 isUserPasswordValid,
40 isUserPasswordValid, 40 isUserRoleValid,
41 isUserRoleValid, 41 isUserUsernameValid,
42 isUserUsernameValid, 42 isUserDisplayNSFWValid
43 isUserDisplayNSFWValid
44 }
45 } 43 }
46} 44}
diff --git a/server/helpers/custom-validators/videos.ts b/server/helpers/custom-validators/videos.ts
index 139fa760f..8b3a26644 100644
--- a/server/helpers/custom-validators/videos.ts
+++ b/server/helpers/custom-validators/videos.ts
@@ -168,35 +168,33 @@ export {
168 isVideoFileResolutionValid 168 isVideoFileResolutionValid
169} 169}
170 170
171declare global { 171declare module 'express-validator' {
172 namespace ExpressValidator { 172 export interface Validator {
173 export interface Validator { 173 isVideoIdOrUUIDValid,
174 isVideoIdOrUUIDValid, 174 isVideoAuthorValid,
175 isVideoAuthorValid, 175 isVideoDateValid,
176 isVideoDateValid, 176 isVideoCategoryValid,
177 isVideoCategoryValid, 177 isVideoLicenceValid,
178 isVideoLicenceValid, 178 isVideoLanguageValid,
179 isVideoLanguageValid, 179 isVideoNSFWValid,
180 isVideoNSFWValid, 180 isVideoDescriptionValid,
181 isVideoDescriptionValid, 181 isVideoDurationValid,
182 isVideoDurationValid, 182 isVideoInfoHashValid,
183 isVideoInfoHashValid, 183 isVideoNameValid,
184 isVideoNameValid, 184 isVideoTagsValid,
185 isVideoTagsValid, 185 isVideoThumbnailValid,
186 isVideoThumbnailValid, 186 isVideoThumbnailDataValid,
187 isVideoThumbnailDataValid, 187 isVideoExtnameValid,
188 isVideoExtnameValid, 188 isVideoUUIDValid,
189 isVideoUUIDValid, 189 isVideoAbuseReasonValid,
190 isVideoAbuseReasonValid, 190 isVideoAbuseReporterUsernameValid,
191 isVideoAbuseReporterUsernameValid, 191 isVideoFile,
192 isVideoFile, 192 isVideoViewsValid,
193 isVideoViewsValid, 193 isVideoLikesValid,
194 isVideoLikesValid, 194 isVideoRatingTypeValid,
195 isVideoRatingTypeValid, 195 isVideoDislikesValid,
196 isVideoDislikesValid, 196 isVideoEventCountValid,
197 isVideoEventCountValid, 197 isVideoFileSizeValid,
198 isVideoFileSizeValid, 198 isVideoFileResolutionValid
199 isVideoFileResolutionValid
200 }
201 } 199 }
202} 200}