]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blob - server/middlewares/validators/shared/video-captions.ts
Add tags to AP rate logger
[github/Chocobozzz/PeerTube.git] / server / middlewares / validators / shared / video-captions.ts
1 import { Response } from 'express'
2 import { VideoCaptionModel } from '@server/models/video/video-caption'
3 import { MVideoId } from '@server/types/models'
4 import { HttpStatusCode } from '@shared/core-utils'
5
6 async function doesVideoCaptionExist (video: MVideoId, language: string, res: Response) {
7 const videoCaption = await VideoCaptionModel.loadByVideoIdAndLanguage(video.id, language)
8
9 if (!videoCaption) {
10 res.fail({
11 status: HttpStatusCode.NOT_FOUND_404,
12 message: 'Video caption not found'
13 })
14 return false
15 }
16
17 res.locals.videoCaption = videoCaption
18 return true
19 }
20
21 // ---------------------------------------------------------------------------
22
23 export {
24 doesVideoCaptionExist
25 }