import { asyncMiddleware, asyncRetryTransactionMiddleware, authenticate } from '../../../middlewares'
import { addVideoCaptionValidator, deleteVideoCaptionValidator, listVideoCaptionsValidator } from '../../../middlewares/validators'
import { createReqFiles } from '../../../helpers/express-utils'
-import { CONFIG, sequelizeTypescript, VIDEO_CAPTIONS_MIMETYPE_EXT } from '../../../initializers'
+import { MIMETYPES } from '../../../initializers/constants'
import { getFormattedObjects } from '../../../helpers/utils'
import { VideoCaptionModel } from '../../../models/video/video-caption'
-import { VideoModel } from '../../../models/video/video'
import { logger } from '../../../helpers/logger'
import { federateVideoIfNeeded } from '../../../lib/activitypub'
import { moveAndProcessCaptionFile } from '../../../helpers/captions-utils'
+import { CONFIG } from '../../../initializers/config'
+import { sequelizeTypescript } from '../../../initializers/database'
const reqVideoCaptionAdd = createReqFiles(
[ 'captionfile' ],
- VIDEO_CAPTIONS_MIMETYPE_EXT,
+ MIMETYPES.VIDEO_CAPTIONS.MIMETYPE_EXT,
{
captionfile: CONFIG.STORAGE.CAPTIONS_DIR
}
async function addVideoCaption (req: express.Request, res: express.Response) {
const videoCaptionPhysicalFile = req.files['captionfile'][0]
- const video = res.locals.video as VideoModel
+ const video = res.locals.video
const videoCaption = new VideoCaptionModel({
videoId: video.id,
}
async function deleteVideoCaption (req: express.Request, res: express.Response) {
- const video = res.locals.video as VideoModel
- const videoCaption = res.locals.videoCaption as VideoCaptionModel
+ const video = res.locals.video
+ const videoCaption = res.locals.videoCaption
await sequelizeTypescript.transaction(async t => {
await videoCaption.destroy({ transaction: t })