From c756bae079e02873f6433582ca14a092fec0db27 Mon Sep 17 00:00:00 2001 From: Rigel Kent Date: Sun, 6 Jun 2021 10:21:06 +0200 Subject: add video upload types, add doc middleware to more routes --- server/middlewares/validators/videos/video-live.ts | 10 ++++++---- server/middlewares/validators/videos/videos.ts | 9 ++++++--- 2 files changed, 12 insertions(+), 7 deletions(-) (limited to 'server/middlewares') 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([ return res.fail({ status: HttpStatusCode.FORBIDDEN_403, - message: 'Live is not enabled on this instance' + message: 'Live is not enabled on this instance', + type: ServerErrorCode.LIVE_NOT_ENABLED }) } @@ -81,7 +82,8 @@ const videoLiveAddValidator = getCommonVideoEditAttributes().concat([ return res.fail({ status: HttpStatusCode.FORBIDDEN_403, - message: 'Saving live replay is not allowed instance' + message: 'Saving live replay is not enabled on this instance', + type: ServerErrorCode.LIVE_NOT_ALLOWING_REPLAY }) } @@ -116,8 +118,8 @@ const videoLiveAddValidator = getCommonVideoEditAttributes().concat([ return res.fail({ status: HttpStatusCode.FORBIDDEN_403, - type: ServerErrorCode.MAX_USER_LIVES_LIMIT_REACHED, - message: 'Cannot create this live because the max user lives limit is reached.' + message: 'Cannot create this live because the max user lives limit is reached.', + type: ServerErrorCode.MAX_USER_LIVES_LIMIT_REACHED }) } } 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 = [ if (isAble === false) { res.fail({ status: HttpStatusCode.PAYLOAD_TOO_LARGE_413, - message: 'The user video quota is exceeded with this video.' + message: 'The user video quota is exceeded with this video.', + type: ServerErrorCode.QUOTA_REACHED }) return } @@ -628,7 +629,8 @@ async function commonVideoChecksPass (parameters: { if (!isVideoFileSizeValid(videoFileSize.toString())) { res.fail({ status: HttpStatusCode.PAYLOAD_TOO_LARGE_413, - message: 'This file is too large. It exceeds the maximum file size authorized.' + message: 'This file is too large. It exceeds the maximum file size authorized.', + type: ServerErrorCode.MAX_FILE_SIZE_REACHED }) return false } @@ -636,7 +638,8 @@ async function commonVideoChecksPass (parameters: { if (await isAbleToUploadVideo(user.id, videoFileSize) === false) { res.fail({ status: HttpStatusCode.PAYLOAD_TOO_LARGE_413, - message: 'The user video quota is exceeded with this video.' + message: 'The user video quota is exceeded with this video.', + type: ServerErrorCode.QUOTA_REACHED }) return false } -- cgit v1.2.3