aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/middlewares/validators
diff options
context:
space:
mode:
authorRigel Kent <sendmemail@rigelk.eu>2021-06-06 10:21:06 +0200
committerRigel Kent <sendmemail@rigelk.eu>2021-06-06 10:21:06 +0200
commitc756bae079e02873f6433582ca14a092fec0db27 (patch)
tree2b24e065144fdb11b8b1ef58ef3157530bd6b2d1 /server/middlewares/validators
parentfc21ef5c62d845576a916414468b3a57370a57b2 (diff)
downloadPeerTube-c756bae079e02873f6433582ca14a092fec0db27.tar.gz
PeerTube-c756bae079e02873f6433582ca14a092fec0db27.tar.zst
PeerTube-c756bae079e02873f6433582ca14a092fec0db27.zip
add video upload types, add doc middleware to more routes
Diffstat (limited to 'server/middlewares/validators')
-rw-r--r--server/middlewares/validators/videos/video-live.ts10
-rw-r--r--server/middlewares/validators/videos/videos.ts9
2 files changed, 12 insertions, 7 deletions
diff --git a/server/middlewares/validators/videos/video-live.ts b/server/middlewares/validators/videos/video-live.ts
index ffc8c47b3..b058ff5c1 100644
--- a/server/middlewares/validators/videos/video-live.ts
+++ b/server/middlewares/validators/videos/video-live.ts
@@ -72,7 +72,8 @@ const videoLiveAddValidator = getCommonVideoEditAttributes().concat([
72 72
73 return res.fail({ 73 return res.fail({
74 status: HttpStatusCode.FORBIDDEN_403, 74 status: HttpStatusCode.FORBIDDEN_403,
75 message: 'Live is not enabled on this instance' 75 message: 'Live is not enabled on this instance',
76 type: ServerErrorCode.LIVE_NOT_ENABLED
76 }) 77 })
77 } 78 }
78 79
@@ -81,7 +82,8 @@ const videoLiveAddValidator = getCommonVideoEditAttributes().concat([
81 82
82 return res.fail({ 83 return res.fail({
83 status: HttpStatusCode.FORBIDDEN_403, 84 status: HttpStatusCode.FORBIDDEN_403,
84 message: 'Saving live replay is not allowed instance' 85 message: 'Saving live replay is not enabled on this instance',
86 type: ServerErrorCode.LIVE_NOT_ALLOWING_REPLAY
85 }) 87 })
86 } 88 }
87 89
@@ -116,8 +118,8 @@ const videoLiveAddValidator = getCommonVideoEditAttributes().concat([
116 118
117 return res.fail({ 119 return res.fail({
118 status: HttpStatusCode.FORBIDDEN_403, 120 status: HttpStatusCode.FORBIDDEN_403,
119 type: ServerErrorCode.MAX_USER_LIVES_LIMIT_REACHED, 121 message: 'Cannot create this live because the max user lives limit is reached.',
120 message: 'Cannot create this live because the max user lives limit is reached.' 122 type: ServerErrorCode.MAX_USER_LIVES_LIMIT_REACHED
121 }) 123 })
122 } 124 }
123 } 125 }
diff --git a/server/middlewares/validators/videos/videos.ts b/server/middlewares/validators/videos/videos.ts
index 52e6c5762..7f278c9f6 100644
--- a/server/middlewares/validators/videos/videos.ts
+++ b/server/middlewares/validators/videos/videos.ts
@@ -402,7 +402,8 @@ const videosAcceptChangeOwnershipValidator = [
402 if (isAble === false) { 402 if (isAble === false) {
403 res.fail({ 403 res.fail({
404 status: HttpStatusCode.PAYLOAD_TOO_LARGE_413, 404 status: HttpStatusCode.PAYLOAD_TOO_LARGE_413,
405 message: 'The user video quota is exceeded with this video.' 405 message: 'The user video quota is exceeded with this video.',
406 type: ServerErrorCode.QUOTA_REACHED
406 }) 407 })
407 return 408 return
408 } 409 }
@@ -628,7 +629,8 @@ async function commonVideoChecksPass (parameters: {
628 if (!isVideoFileSizeValid(videoFileSize.toString())) { 629 if (!isVideoFileSizeValid(videoFileSize.toString())) {
629 res.fail({ 630 res.fail({
630 status: HttpStatusCode.PAYLOAD_TOO_LARGE_413, 631 status: HttpStatusCode.PAYLOAD_TOO_LARGE_413,
631 message: 'This file is too large. It exceeds the maximum file size authorized.' 632 message: 'This file is too large. It exceeds the maximum file size authorized.',
633 type: ServerErrorCode.MAX_FILE_SIZE_REACHED
632 }) 634 })
633 return false 635 return false
634 } 636 }
@@ -636,7 +638,8 @@ async function commonVideoChecksPass (parameters: {
636 if (await isAbleToUploadVideo(user.id, videoFileSize) === false) { 638 if (await isAbleToUploadVideo(user.id, videoFileSize) === false) {
637 res.fail({ 639 res.fail({
638 status: HttpStatusCode.PAYLOAD_TOO_LARGE_413, 640 status: HttpStatusCode.PAYLOAD_TOO_LARGE_413,
639 message: 'The user video quota is exceeded with this video.' 641 message: 'The user video quota is exceeded with this video.',
642 type: ServerErrorCode.QUOTA_REACHED
640 }) 643 })
641 return false 644 return false
642 } 645 }