- checkErrors(req, res, () => {
- checkVideoExists(req.params.id, res, next)
- })
+ if (areValidationErrors(req, res)) return
+ if (!await isVideoExist(req.params.id, res)) return
+
+ return next()
+ }
+]
+
+const videosShareValidator = [
+ param('id').custom(isIdOrUUIDValid).not().isEmpty().withMessage('Should have a valid id'),
+ param('accountId').custom(isIdValid).not().isEmpty().withMessage('Should have a valid account id'),
+
+ async (req: express.Request, res: express.Response, next: express.NextFunction) => {
+ logger.debug('Checking videoShare parameters', { parameters: req.params })
+
+ if (areValidationErrors(req, res)) return
+ if (!await isVideoExist(req.params.id, res)) return
+
+ const share = await db.VideoShare.load(req.params.accountId, res.locals.video.id, undefined)
+ if (!share) {
+ return res.status(404)
+ .end()
+ }
+
+ res.locals.videoShare = share
+ return next()