]>
Commit | Line | Data |
---|---|---|
3e753302 C |
1 | import { Response } from 'express' |
2 | import { VideoCaptionModel } from '../../models/video/video-caption' | |
26d6bf65 | 3 | import { MVideoId } from '@server/types/models' |
2d53be02 | 4 | import { HttpStatusCode } from '../../../shared/core-utils/miscs/http-error-codes' |
3e753302 | 5 | |
453e83ea | 6 | async function doesVideoCaptionExist (video: MVideoId, language: string, res: Response) { |
3e753302 C |
7 | const videoCaption = await VideoCaptionModel.loadByVideoIdAndLanguage(video.id, language) |
8 | ||
9 | if (!videoCaption) { | |
2d53be02 | 10 | res.status(HttpStatusCode.NOT_FOUND_404) |
3e753302 | 11 | .json({ error: 'Video caption not found' }) |
3e753302 C |
12 | |
13 | return false | |
14 | } | |
15 | ||
16 | res.locals.videoCaption = videoCaption | |
17 | return true | |
18 | } | |
19 | ||
20 | // --------------------------------------------------------------------------- | |
21 | ||
22 | export { | |
23 | doesVideoCaptionExist | |
24 | } |