diff options
Diffstat (limited to 'server/middlewares/validators/video-captions.ts')
-rw-r--r-- | server/middlewares/validators/video-captions.ts | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/server/middlewares/validators/video-captions.ts b/server/middlewares/validators/video-captions.ts index b6d92d380..18d537bc4 100644 --- a/server/middlewares/validators/video-captions.ts +++ b/server/middlewares/validators/video-captions.ts | |||
@@ -7,6 +7,7 @@ import { CONSTRAINTS_FIELDS } from '../../initializers' | |||
7 | import { UserRight } from '../../../shared' | 7 | import { UserRight } from '../../../shared' |
8 | import { logger } from '../../helpers/logger' | 8 | import { logger } from '../../helpers/logger' |
9 | import { isVideoCaptionExist, isVideoCaptionFile, isVideoCaptionLanguageValid } from '../../helpers/custom-validators/video-captions' | 9 | import { isVideoCaptionExist, isVideoCaptionFile, isVideoCaptionLanguageValid } from '../../helpers/custom-validators/video-captions' |
10 | import { cleanUpReqFiles } from '../../helpers/utils' | ||
10 | 11 | ||
11 | const addVideoCaptionValidator = [ | 12 | const addVideoCaptionValidator = [ |
12 | param('videoId').custom(isIdOrUUIDValid).not().isEmpty().withMessage('Should have a valid video id'), | 13 | param('videoId').custom(isIdOrUUIDValid).not().isEmpty().withMessage('Should have a valid video id'), |
@@ -20,12 +21,12 @@ const addVideoCaptionValidator = [ | |||
20 | async (req: express.Request, res: express.Response, next: express.NextFunction) => { | 21 | async (req: express.Request, res: express.Response, next: express.NextFunction) => { |
21 | logger.debug('Checking addVideoCaption parameters', { parameters: req.body }) | 22 | logger.debug('Checking addVideoCaption parameters', { parameters: req.body }) |
22 | 23 | ||
23 | if (areValidationErrors(req, res)) return | 24 | if (areValidationErrors(req, res)) return cleanUpReqFiles(req) |
24 | if (!await isVideoExist(req.params.videoId, res)) return | 25 | if (!await isVideoExist(req.params.videoId, res)) return cleanUpReqFiles(req) |
25 | 26 | ||
26 | // Check if the user who did the request is able to update the video | 27 | // Check if the user who did the request is able to update the video |
27 | const user = res.locals.oauth.token.User | 28 | const user = res.locals.oauth.token.User |
28 | if (!checkUserCanManageVideo(user, res.locals.video, UserRight.UPDATE_ANY_VIDEO, res)) return | 29 | if (!checkUserCanManageVideo(user, res.locals.video, UserRight.UPDATE_ANY_VIDEO, res)) return cleanUpReqFiles(req) |
29 | 30 | ||
30 | return next() | 31 | return next() |
31 | } | 32 | } |