import { cleanUpReqFiles } from '../../../helpers/express-utils'
import { logger } from '../../../helpers/logger'
import { CONSTRAINTS_FIELDS, MIMETYPES } from '../../../initializers/constants'
-import { areValidationErrors, checkUserCanManageVideo, doesVideoCaptionExist, doesVideoExist, isValidVideoIdParam } from '../shared'
+import {
+ areValidationErrors,
+ checkCanSeeVideo,
+ checkUserCanManageVideo,
+ doesVideoCaptionExist,
+ doesVideoExist,
+ isValidVideoIdParam
+} from '../shared'
const addVideoCaptionValidator = [
isValidVideoIdParam('videoId'),
logger.debug('Checking listVideoCaptions parameters', { parameters: req.params })
if (areValidationErrors(req, res)) return
- if (!await doesVideoExist(req.params.videoId, res, 'id')) return
+ if (!await doesVideoExist(req.params.videoId, res, 'only-video')) return
+
+ const video = res.locals.onlyVideo
+ if (!await checkCanSeeVideo({ req, res, video, paramId: req.params.videoId })) return
return next()
}