aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/controllers
diff options
context:
space:
mode:
Diffstat (limited to 'server/controllers')
-rw-r--r--server/controllers/api/users.ts30
1 files changed, 29 insertions, 1 deletions
diff --git a/server/controllers/api/users.ts b/server/controllers/api/users.ts
index dbe736bff..6e5f9913e 100644
--- a/server/controllers/api/users.ts
+++ b/server/controllers/api/users.ts
@@ -29,7 +29,12 @@ import {
29 usersUpdateValidator, 29 usersUpdateValidator,
30 usersVideoRatingValidator 30 usersVideoRatingValidator
31} from '../../middlewares' 31} from '../../middlewares'
32import { usersAskResetPasswordValidator, usersResetPasswordValidator, videosSortValidator } from '../../middlewares/validators' 32import {
33 usersAskResetPasswordValidator,
34 usersResetPasswordValidator,
35 videoImportsSortValidator,
36 videosSortValidator
37} from '../../middlewares/validators'
33import { AccountVideoRateModel } from '../../models/account/account-video-rate' 38import { AccountVideoRateModel } from '../../models/account/account-video-rate'
34import { UserModel } from '../../models/account/user' 39import { UserModel } from '../../models/account/user'
35import { OAuthTokenModel } from '../../models/oauth/oauth-token' 40import { OAuthTokenModel } from '../../models/oauth/oauth-token'
@@ -40,6 +45,7 @@ import { UserVideoQuota } from '../../../shared/models/users/user-video-quota.mo
40import { updateAvatarValidator } from '../../middlewares/validators/avatar' 45import { updateAvatarValidator } from '../../middlewares/validators/avatar'
41import { updateActorAvatarFile } from '../../lib/avatar' 46import { updateActorAvatarFile } from '../../lib/avatar'
42import { auditLoggerFactory, UserAuditView } from '../../helpers/audit-logger' 47import { auditLoggerFactory, UserAuditView } from '../../helpers/audit-logger'
48import { VideoImportModel } from '../../models/video/video-import'
43 49
44const auditLogger = auditLoggerFactory('users') 50const auditLogger = auditLoggerFactory('users')
45 51
@@ -62,6 +68,16 @@ usersRouter.get('/me/video-quota-used',
62 asyncMiddleware(getUserVideoQuotaUsed) 68 asyncMiddleware(getUserVideoQuotaUsed)
63) 69)
64 70
71
72usersRouter.get('/me/videos/imports',
73 authenticate,
74 paginationValidator,
75 videoImportsSortValidator,
76 setDefaultSort,
77 setDefaultPagination,
78 asyncMiddleware(getUserVideoImports)
79)
80
65usersRouter.get('/me/videos', 81usersRouter.get('/me/videos',
66 authenticate, 82 authenticate,
67 paginationValidator, 83 paginationValidator,
@@ -178,6 +194,18 @@ async function getUserVideos (req: express.Request, res: express.Response, next:
178 return res.json(getFormattedObjects(resultList.data, resultList.total, { additionalAttributes })) 194 return res.json(getFormattedObjects(resultList.data, resultList.total, { additionalAttributes }))
179} 195}
180 196
197async function getUserVideoImports (req: express.Request, res: express.Response, next: express.NextFunction) {
198 const user = res.locals.oauth.token.User as UserModel
199 const resultList = await VideoImportModel.listUserVideoImportsForApi(
200 user.Account.id,
201 req.query.start as number,
202 req.query.count as number,
203 req.query.sort
204 )
205
206 return res.json(getFormattedObjects(resultList.data, resultList.total))
207}
208
181async function createUser (req: express.Request, res: express.Response) { 209async function createUser (req: express.Request, res: express.Response) {
182 const body: UserCreate = req.body 210 const body: UserCreate = req.body
183 const userToCreate = new UserModel({ 211 const userToCreate = new UserModel({