]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blobdiff - server/middlewares/validators/videos/video-live.ts
Fetch directly all video attributes for get API
[github/Chocobozzz/PeerTube.git] / server / middlewares / validators / videos / video-live.ts
index 9544fa4f501a804286c297a120ffadc923829c77..b058ff5c189a91968c68ea149117c2d06df3073d 100644 (file)
@@ -1,20 +1,19 @@
 import * as express from 'express'
 import { body, param } from 'express-validator'
-import { checkUserCanManageVideo, doesVideoChannelOfAccountExist, doesVideoExist } from '@server/helpers/middlewares/videos'
+import { CONSTRAINTS_FIELDS } from '@server/initializers/constants'
+import { isLocalLiveVideoAccepted } from '@server/lib/moderation'
+import { Hooks } from '@server/lib/plugins/hooks'
+import { VideoModel } from '@server/models/video/video'
 import { VideoLiveModel } from '@server/models/video/video-live'
+import { HttpStatusCode } from '@shared/core-utils/miscs/http-error-codes'
 import { ServerErrorCode, UserRight, VideoState } from '@shared/models'
 import { isBooleanValid, isIdOrUUIDValid, isIdValid, toBooleanOrNull, toIntOrNull } from '../../../helpers/custom-validators/misc'
 import { isVideoNameValid } from '../../../helpers/custom-validators/videos'
 import { cleanUpReqFiles } from '../../../helpers/express-utils'
 import { logger } from '../../../helpers/logger'
 import { CONFIG } from '../../../initializers/config'
-import { areValidationErrors } from '../utils'
+import { areValidationErrors, checkUserCanManageVideo, doesVideoChannelOfAccountExist, doesVideoExist } from '../shared'
 import { getCommonVideoEditAttributes } from './videos'
-import { VideoModel } from '@server/models/video/video'
-import { Hooks } from '@server/lib/plugins/hooks'
-import { isLocalLiveVideoAccepted } from '@server/lib/moderation'
-import { HttpStatusCode } from '@shared/core-utils/miscs/http-error-codes'
-import { CONSTRAINTS_FIELDS } from '@server/initializers/constants'
 
 const videoLiveGetValidator = [
   param('videoId').custom(isIdOrUUIDValid).not().isEmpty().withMessage('Should have a valid videoId'),
@@ -73,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
       })
     }
 
@@ -82,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
       })
     }
 
@@ -104,7 +105,7 @@ const videoLiveAddValidator = getCommonVideoEditAttributes().concat([
         return res.fail({
           status: HttpStatusCode.FORBIDDEN_403,
           message: 'Cannot create this live because the max instance lives limit is reached.',
-          type: ServerErrorCode.MAX_INSTANCE_LIVES_LIMIT_REACHED.toString()
+          type: ServerErrorCode.MAX_INSTANCE_LIVES_LIMIT_REACHED
         })
       }
     }
@@ -117,8 +118,8 @@ const videoLiveAddValidator = getCommonVideoEditAttributes().concat([
 
         return res.fail({
           status: HttpStatusCode.FORBIDDEN_403,
-          type: ServerErrorCode.MAX_USER_LIVES_LIMIT_REACHED.toString(),
-          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
         })
       }
     }