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