]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blobdiff - server/controllers/api/users.ts
Add concept of video state, and add ability to wait transcoding before
[github/Chocobozzz/PeerTube.git] / server / controllers / api / users.ts
index 0a591f11dd121866f373df7a18a8cf89d1994718..2b40c44d95887608850a2b0ea556c95952043c66 100644 (file)
@@ -19,6 +19,7 @@ import {
   authenticate,
   ensureUserHasRight,
   ensureUserRegistrationAllowed,
+  ensureUserRegistrationAllowedForIP,
   paginationValidator,
   setDefaultPagination,
   setDefaultSort,
@@ -106,6 +107,7 @@ usersRouter.post('/',
 
 usersRouter.post('/register',
   asyncMiddleware(ensureUserRegistrationAllowed),
+  ensureUserRegistrationAllowedForIP,
   asyncMiddleware(usersRegisterValidator),
   asyncMiddleware(registerUserRetryWrapper)
 )
@@ -164,7 +166,7 @@ export {
 
 async function getUserVideos (req: express.Request, res: express.Response, next: express.NextFunction) {
   const user = res.locals.oauth.token.User as UserModel
-  const resultList = await VideoModel.listAccountVideosForApi(
+  const resultList = await VideoModel.listUserVideosForApi(
     user.Account.id,
     req.query.start as number,
     req.query.count as number,
@@ -172,7 +174,8 @@ async function getUserVideos (req: express.Request, res: express.Response, next:
     false // Display my NSFW videos
   )
 
-  return res.json(getFormattedObjects(resultList.data, resultList.total))
+  const additionalAttributes = { waitTranscoding: true, state: true }
+  return res.json(getFormattedObjects(resultList.data, resultList.total, { additionalAttributes }))
 }
 
 async function createUserRetryWrapper (req: express.Request, res: express.Response, next: express.NextFunction) {
@@ -316,7 +319,7 @@ async function updateMe (req: express.Request, res: express.Response, next: expr
 }
 
 async function updateMyAvatar (req: express.Request, res: express.Response, next: express.NextFunction) {
-  const avatarPhysicalFile = req.files['avatarfile'][0]
+  const avatarPhysicalFile = req.files[ 'avatarfile' ][ 0 ]
   const user = res.locals.oauth.token.user
   const actor = user.Account.Actor