aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/helpers/custom-validators/videos.ts
diff options
context:
space:
mode:
authorChocobozzz <florian.bigard@gmail.com>2017-07-11 16:01:56 +0200
committerChocobozzz <florian.bigard@gmail.com>2017-07-11 16:01:56 +0200
commit0a6658fdcbd779ada8f3758048c326e997902d5a (patch)
tree5de40bf901db0299011104b1344783637b964eb0 /server/helpers/custom-validators/videos.ts
parente6d4b0ff2404dcf0b3a755c3fcc415ffeb6e754d (diff)
downloadPeerTube-0a6658fdcbd779ada8f3758048c326e997902d5a.tar.gz
PeerTube-0a6658fdcbd779ada8f3758048c326e997902d5a.tar.zst
PeerTube-0a6658fdcbd779ada8f3758048c326e997902d5a.zip
Use global uuid instead of remoteId for videos
Diffstat (limited to 'server/helpers/custom-validators/videos.ts')
-rw-r--r--server/helpers/custom-validators/videos.ts14
1 files changed, 10 insertions, 4 deletions
diff --git a/server/helpers/custom-validators/videos.ts b/server/helpers/custom-validators/videos.ts
index 72d226e81..e335b09d1 100644
--- a/server/helpers/custom-validators/videos.ts
+++ b/server/helpers/custom-validators/videos.ts
@@ -17,6 +17,10 @@ const VIDEOS_CONSTRAINTS_FIELDS = CONSTRAINTS_FIELDS.VIDEOS
17const VIDEO_ABUSES_CONSTRAINTS_FIELDS = CONSTRAINTS_FIELDS.VIDEO_ABUSES 17const VIDEO_ABUSES_CONSTRAINTS_FIELDS = CONSTRAINTS_FIELDS.VIDEO_ABUSES
18const VIDEO_EVENTS_CONSTRAINTS_FIELDS = CONSTRAINTS_FIELDS.VIDEO_EVENTS 18const VIDEO_EVENTS_CONSTRAINTS_FIELDS = CONSTRAINTS_FIELDS.VIDEO_EVENTS
19 19
20function isVideoIdOrUUIDValid (value: string) {
21 return validator.isInt(value) || isVideoUUIDValid(value)
22}
23
20function isVideoAuthorValid (value: string) { 24function isVideoAuthorValid (value: string) {
21 return isUserUsernameValid(value) 25 return isUserUsernameValid(value)
22} 26}
@@ -77,8 +81,8 @@ function isVideoThumbnailDataValid (value: string) {
77 return exists(value) && validator.isByteLength(value, VIDEOS_CONSTRAINTS_FIELDS.THUMBNAIL_DATA) 81 return exists(value) && validator.isByteLength(value, VIDEOS_CONSTRAINTS_FIELDS.THUMBNAIL_DATA)
78} 82}
79 83
80function isVideoRemoteIdValid (value: string) { 84function isVideoUUIDValid (value: string) {
81 return exists(value) && validator.isUUID(value, 4) 85 return exists(value) && validator.isUUID('' + value, 4)
82} 86}
83 87
84function isVideoAbuseReasonValid (value: string) { 88function isVideoAbuseReasonValid (value: string) {
@@ -127,6 +131,7 @@ function isVideoFile (value: string, files: { [ fieldname: string ]: Express.Mul
127// --------------------------------------------------------------------------- 131// ---------------------------------------------------------------------------
128 132
129export { 133export {
134 isVideoIdOrUUIDValid,
130 isVideoAuthorValid, 135 isVideoAuthorValid,
131 isVideoDateValid, 136 isVideoDateValid,
132 isVideoCategoryValid, 137 isVideoCategoryValid,
@@ -141,7 +146,7 @@ export {
141 isVideoThumbnailValid, 146 isVideoThumbnailValid,
142 isVideoThumbnailDataValid, 147 isVideoThumbnailDataValid,
143 isVideoExtnameValid, 148 isVideoExtnameValid,
144 isVideoRemoteIdValid, 149 isVideoUUIDValid,
145 isVideoAbuseReasonValid, 150 isVideoAbuseReasonValid,
146 isVideoAbuseReporterUsernameValid, 151 isVideoAbuseReporterUsernameValid,
147 isVideoFile, 152 isVideoFile,
@@ -155,6 +160,7 @@ export {
155declare global { 160declare global {
156 namespace ExpressValidator { 161 namespace ExpressValidator {
157 export interface Validator { 162 export interface Validator {
163 isVideoIdOrUUIDValid,
158 isVideoAuthorValid, 164 isVideoAuthorValid,
159 isVideoDateValid, 165 isVideoDateValid,
160 isVideoCategoryValid, 166 isVideoCategoryValid,
@@ -169,7 +175,7 @@ declare global {
169 isVideoThumbnailValid, 175 isVideoThumbnailValid,
170 isVideoThumbnailDataValid, 176 isVideoThumbnailDataValid,
171 isVideoExtnameValid, 177 isVideoExtnameValid,
172 isVideoRemoteIdValid, 178 isVideoUUIDValid,
173 isVideoAbuseReasonValid, 179 isVideoAbuseReasonValid,
174 isVideoAbuseReporterUsernameValid, 180 isVideoAbuseReporterUsernameValid,
175 isVideoFile, 181 isVideoFile,