aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/controllers/api
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2018-01-08 12:53:09 +0100
committerChocobozzz <me@florianbigard.com>2018-01-08 12:53:09 +0100
commitce5496d6a31b9617aba67970f5dc135e73335234 (patch)
treeb5d2578f4618b71632e92838c3ceae36aa102798 /server/controllers/api
parent108af66140713c4beec681a71d360ab788226528 (diff)
downloadPeerTube-ce5496d6a31b9617aba67970f5dc135e73335234.tar.gz
PeerTube-ce5496d6a31b9617aba67970f5dc135e73335234.tar.zst
PeerTube-ce5496d6a31b9617aba67970f5dc135e73335234.zip
Support video quota on client
Diffstat (limited to 'server/controllers/api')
-rw-r--r--server/controllers/api/users.ts17
1 files changed, 16 insertions, 1 deletions
diff --git a/server/controllers/api/users.ts b/server/controllers/api/users.ts
index 2d77a5249..5374c4b6a 100644
--- a/server/controllers/api/users.ts
+++ b/server/controllers/api/users.ts
@@ -30,6 +30,11 @@ usersRouter.get('/me',
30 asyncMiddleware(getUserInformation) 30 asyncMiddleware(getUserInformation)
31) 31)
32 32
33usersRouter.get('/me/video-quota-used',
34 authenticate,
35 asyncMiddleware(getUserVideoQuotaUsed)
36)
37
33usersRouter.get('/me/videos', 38usersRouter.get('/me/videos',
34 authenticate, 39 authenticate,
35 paginationValidator, 40 paginationValidator,
@@ -183,8 +188,18 @@ async function getUserInformation (req: express.Request, res: express.Response,
183 return res.json(user.toFormattedJSON()) 188 return res.json(user.toFormattedJSON())
184} 189}
185 190
191async function getUserVideoQuotaUsed (req: express.Request, res: express.Response, next: express.NextFunction) {
192 // We did not load channels in res.locals.user
193 const user = await UserModel.loadByUsernameAndPopulateChannels(res.locals.oauth.token.user.username)
194 const videoQuotaUsed = await UserModel.getOriginalVideoFileTotalFromUser(user)
195
196 return res.json({
197 videoQuotaUsed
198 })
199}
200
186function getUser (req: express.Request, res: express.Response, next: express.NextFunction) { 201function getUser (req: express.Request, res: express.Response, next: express.NextFunction) {
187 return res.json(res.locals.user.toFormattedJSON()) 202 return res.json((res.locals.user as UserModel).toFormattedJSON())
188} 203}
189 204
190async function getUserVideoRating (req: express.Request, res: express.Response, next: express.NextFunction) { 205async function getUserVideoRating (req: express.Request, res: express.Response, next: express.NextFunction) {