]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blobdiff - server/controllers/api/videos/index.ts
Add explicit error message that changing video ownership only works with local accou...
[github/Chocobozzz/PeerTube.git] / server / controllers / api / videos / index.ts
index 581046782e775b68c3bfcd4218d04d1e10153cee..6a73e13d00c64da1b16ad5c77baefb6fad89e543 100644 (file)
@@ -57,6 +57,7 @@ import { videoCaptionsRouter } from './captions'
 import { videoImportsRouter } from './import'
 import { resetSequelizeInstance } from '../../../helpers/database-utils'
 import { rename } from 'fs-extra'
+import { watchingRouter } from './watching'
 
 const auditLogger = auditLoggerFactory('videos')
 const videosRouter = express.Router()
@@ -86,6 +87,7 @@ videosRouter.use('/', videoCommentRouter)
 videosRouter.use('/', videoCaptionsRouter)
 videosRouter.use('/', videoImportsRouter)
 videosRouter.use('/', ownershipVideoRouter)
+videosRouter.use('/', watchingRouter)
 
 videosRouter.get('/categories', listVideoCategories)
 videosRouter.get('/licences', listVideoLicences)
@@ -119,6 +121,7 @@ videosRouter.get('/:id/description',
   asyncMiddleware(getVideoDescription)
 )
 videosRouter.get('/:id',
+  optionalAuthenticate,
   asyncMiddleware(videosGetValidator),
   getVideo
 )
@@ -158,6 +161,13 @@ function listVideoPrivacies (req: express.Request, res: express.Response) {
 }
 
 async function addVideo (req: express.Request, res: express.Response) {
+  // Processing the video could be long
+  // Set timeout to 10 minutes
+  req.setTimeout(1000 * 60 * 10, () => {
+    logger.error('Upload video has timed out.')
+    return res.sendStatus(408)
+  })
+
   const videoPhysicalFile = req.files['videofile'][0]
   const videoInfo: VideoCreate = req.body
 
@@ -426,7 +436,8 @@ async function listVideos (req: express.Request, res: express.Response, next: ex
     tagsAllOf: req.query.tagsAllOf,
     nsfw: buildNSFWFilter(res, req.query.nsfw),
     filter: req.query.filter as VideoFilter,
-    withFiles: false
+    withFiles: false,
+    userId: res.locals.oauth ? res.locals.oauth.token.User.id : undefined
   })
 
   return res.json(getFormattedObjects(resultList.data, resultList.total))