]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blobdiff - server/controllers/api/videos/captions.ts
refactor 404 page
[github/Chocobozzz/PeerTube.git] / server / controllers / api / videos / captions.ts
index 44c255232bd83cd8d467139091d32c03c89672cd..c4e2ee72ca03f8c0e3573e66a29b13bd3642f2c5 100644 (file)
@@ -6,10 +6,11 @@ import { MIMETYPES } from '../../../initializers/constants'
 import { getFormattedObjects } from '../../../helpers/utils'
 import { VideoCaptionModel } from '../../../models/video/video-caption'
 import { logger } from '../../../helpers/logger'
-import { federateVideoIfNeeded } from '../../../lib/activitypub'
+import { federateVideoIfNeeded } from '../../../lib/activitypub/videos'
 import { moveAndProcessCaptionFile } from '../../../helpers/captions-utils'
 import { CONFIG } from '../../../initializers/config'
 import { sequelizeTypescript } from '../../../initializers/database'
+import { MVideoCaptionVideo } from '@server/types/models'
 
 const reqVideoCaptionAdd = createReqFiles(
   [ 'captionfile' ],
@@ -46,26 +47,26 @@ export {
 // ---------------------------------------------------------------------------
 
 async function listVideoCaptions (req: express.Request, res: express.Response) {
-  const data = await VideoCaptionModel.listVideoCaptions(res.locals.video.id)
+  const data = await VideoCaptionModel.listVideoCaptions(res.locals.videoId.id)
 
   return res.json(getFormattedObjects(data, data.length))
 }
 
 async function addVideoCaption (req: express.Request, res: express.Response) {
   const videoCaptionPhysicalFile = req.files['captionfile'][0]
-  const video = res.locals.video
+  const video = res.locals.videoAll
 
   const videoCaption = new VideoCaptionModel({
     videoId: video.id,
     language: req.params.captionLanguage
-  })
+  }) as MVideoCaptionVideo
   videoCaption.Video = video
 
   // Move physical file
   await moveAndProcessCaptionFile(videoCaptionPhysicalFile, videoCaption)
 
   await sequelizeTypescript.transaction(async t => {
-    await VideoCaptionModel.insertOrReplaceLanguage(video.id, req.params.captionLanguage, t)
+    await VideoCaptionModel.insertOrReplaceLanguage(video.id, req.params.captionLanguage, null, t)
 
     // Update video update
     await federateVideoIfNeeded(video, false, t)
@@ -75,7 +76,7 @@ async function addVideoCaption (req: express.Request, res: express.Response) {
 }
 
 async function deleteVideoCaption (req: express.Request, res: express.Response) {
-  const video = res.locals.video
+  const video = res.locals.videoAll
   const videoCaption = res.locals.videoCaption
 
   await sequelizeTypescript.transaction(async t => {