]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blobdiff - server/middlewares/validators/videos/videos.ts
Add ability to search playlists
[github/Chocobozzz/PeerTube.git] / server / middlewares / validators / videos / videos.ts
index 52e6c57622db2bc81e61f15a0b962bd22ea2bce6..2bed5f18123b09ff9e5ce1a4538d1ab2b7902ee5 100644 (file)
@@ -4,7 +4,7 @@ import { getResumableUploadPath } from '@server/helpers/upload'
 import { isAbleToUploadVideo } from '@server/lib/user'
 import { getServerActor } from '@server/models/application/application'
 import { ExpressPromiseHandler } from '@server/types/express'
-import { MUserAccountId, MVideoWithRights } from '@server/types/models'
+import { MUserAccountId, MVideoFullLight } from '@server/types/models'
 import { ServerErrorCode, UserRight, VideoChangeOwnershipStatus, VideoPrivacy } from '../../../../shared'
 import { HttpStatusCode } from '../../../../shared/core-utils/miscs/http-error-codes'
 import { VideoChangeOwnershipAccept } from '../../../../shared/models/videos/change-ownership/video-change-ownership-accept.model'
@@ -258,7 +258,7 @@ async function checkVideoFollowConstraints (req: express.Request, res: express.R
 }
 
 const videosCustomGetValidator = (
-  fetchType: 'all' | 'only-video' | 'only-video-with-rights' | 'only-immutable-attributes',
+  fetchType: 'for-api' | 'all' | 'only-video' | 'only-immutable-attributes',
   authenticateInQuery = false
 ) => {
   return [
@@ -273,7 +273,7 @@ const videosCustomGetValidator = (
       // Controllers does not need to check video rights
       if (fetchType === 'only-immutable-attributes') return next()
 
-      const video = getVideoWithAttributes(res) as MVideoWithRights
+      const video = getVideoWithAttributes(res) as MVideoFullLight
 
       // Video private or blacklisted
       if (video.requiresAuth()) {
@@ -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
   }