2019-07-23 08:40:39 +00:00
|
|
|
import { Response } from 'express'
|
2021-06-03 15:33:44 +00:00
|
|
|
import { VideoCaptionModel } from '@server/models/video/video-caption'
|
2020-06-18 08:45:25 +00:00
|
|
|
import { MVideoId } from '@server/types/models'
|
2021-06-03 15:33:44 +00:00
|
|
|
import { HttpStatusCode } from '@shared/core-utils'
|
2019-07-23 08:40:39 +00:00
|
|
|
|
2019-08-15 09:53:26 +00:00
|
|
|
async function doesVideoCaptionExist (video: MVideoId, language: string, res: Response) {
|
2019-07-23 08:40:39 +00:00
|
|
|
const videoCaption = await VideoCaptionModel.loadByVideoIdAndLanguage(video.id, language)
|
|
|
|
|
|
|
|
if (!videoCaption) {
|
2021-05-31 23:36:53 +00:00
|
|
|
res.fail({
|
|
|
|
status: HttpStatusCode.NOT_FOUND_404,
|
|
|
|
message: 'Video caption not found'
|
|
|
|
})
|
2019-07-23 08:40:39 +00:00
|
|
|
return false
|
|
|
|
}
|
|
|
|
|
|
|
|
res.locals.videoCaption = videoCaption
|
|
|
|
return true
|
|
|
|
}
|
|
|
|
|
|
|
|
// ---------------------------------------------------------------------------
|
|
|
|
|
|
|
|
export {
|
|
|
|
doesVideoCaptionExist
|
|
|
|
}
|