]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blame - server/helpers/middlewares/video-captions.ts
Refactor middleware helpers
[github/Chocobozzz/PeerTube.git] / server / helpers / middlewares / video-captions.ts
CommitLineData
3e753302
C
1import { VideoModel } from '../../models/video/video'
2import { Response } from 'express'
3import { VideoCaptionModel } from '../../models/video/video-caption'
4
5async function doesVideoCaptionExist (video: VideoModel, language: string, res: Response) {
6 const videoCaption = await VideoCaptionModel.loadByVideoIdAndLanguage(video.id, language)
7
8 if (!videoCaption) {
9 res.status(404)
10 .json({ error: 'Video caption not found' })
11 .end()
12
13 return false
14 }
15
16 res.locals.videoCaption = videoCaption
17 return true
18}
19
20// ---------------------------------------------------------------------------
21
22export {
23 doesVideoCaptionExist
24}