1
0
Fork 0
mirror of https://github.com/Chocobozzz/PeerTube.git synced 2025-10-05 02:39:33 +02:00

Support video quota on client

This commit is contained in:
Chocobozzz 2018-01-08 12:53:09 +01:00
parent 108af66140
commit ce5496d6a3
No known key found for this signature in database
GPG key ID: 583A612D890159BE
14 changed files with 93 additions and 36 deletions

View file

@ -30,6 +30,11 @@ usersRouter.get('/me',
asyncMiddleware(getUserInformation)
)
usersRouter.get('/me/video-quota-used',
authenticate,
asyncMiddleware(getUserVideoQuotaUsed)
)
usersRouter.get('/me/videos',
authenticate,
paginationValidator,
@ -183,8 +188,18 @@ async function getUserInformation (req: express.Request, res: express.Response,
return res.json(user.toFormattedJSON())
}
async function getUserVideoQuotaUsed (req: express.Request, res: express.Response, next: express.NextFunction) {
// We did not load channels in res.locals.user
const user = await UserModel.loadByUsernameAndPopulateChannels(res.locals.oauth.token.user.username)
const videoQuotaUsed = await UserModel.getOriginalVideoFileTotalFromUser(user)
return res.json({
videoQuotaUsed
})
}
function getUser (req: express.Request, res: express.Response, next: express.NextFunction) {
return res.json(res.locals.user.toFormattedJSON())
return res.json((res.locals.user as UserModel).toFormattedJSON())
}
async function getUserVideoRating (req: express.Request, res: express.Response, next: express.NextFunction) {