aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/controllers/api/users.ts
diff options
context:
space:
mode:
Diffstat (limited to 'server/controllers/api/users.ts')
-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) {