1 import express from 'express'
2 import { param } from 'express-validator'
3 import { HttpStatusCode } from '../../../../shared/models/http/http-error-codes'
4 import { isIdValid } from '../../../helpers/custom-validators/misc'
5 import { logger } from '../../../helpers/logger'
6 import { VideoShareModel } from '../../../models/video/video-share'
7 import { areValidationErrors, doesVideoExist, isValidVideoIdParam } from '../shared'
9 const videosShareValidator = [
10 isValidVideoIdParam('id'),
13 .custom(isIdValid).not().isEmpty().withMessage('Should have a valid actor id'),
15 async (req: express.Request, res: express.Response, next: express.NextFunction) => {
16 logger.debug('Checking videoShare parameters', { parameters: req.params })
18 if (areValidationErrors(req, res)) return
19 if (!await doesVideoExist(req.params.id, res)) return
21 const video = res.locals.videoAll
23 const share = await VideoShareModel.load(req.params.actorId, video.id)
25 return res.status(HttpStatusCode.NOT_FOUND_404)
29 res.locals.videoShare = share
34 // ---------------------------------------------------------------------------