diff options
Diffstat (limited to 'server/controllers/api')
-rw-r--r-- | server/controllers/api/users.ts | 30 |
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' |
32 | import { usersAskResetPasswordValidator, usersResetPasswordValidator, videosSortValidator } from '../../middlewares/validators' | 32 | import { |
33 | usersAskResetPasswordValidator, | ||
34 | usersResetPasswordValidator, | ||
35 | videoImportsSortValidator, | ||
36 | videosSortValidator | ||
37 | } from '../../middlewares/validators' | ||
33 | import { AccountVideoRateModel } from '../../models/account/account-video-rate' | 38 | import { AccountVideoRateModel } from '../../models/account/account-video-rate' |
34 | import { UserModel } from '../../models/account/user' | 39 | import { UserModel } from '../../models/account/user' |
35 | import { OAuthTokenModel } from '../../models/oauth/oauth-token' | 40 | import { OAuthTokenModel } from '../../models/oauth/oauth-token' |
@@ -40,6 +45,7 @@ import { UserVideoQuota } from '../../../shared/models/users/user-video-quota.mo | |||
40 | import { updateAvatarValidator } from '../../middlewares/validators/avatar' | 45 | import { updateAvatarValidator } from '../../middlewares/validators/avatar' |
41 | import { updateActorAvatarFile } from '../../lib/avatar' | 46 | import { updateActorAvatarFile } from '../../lib/avatar' |
42 | import { auditLoggerFactory, UserAuditView } from '../../helpers/audit-logger' | 47 | import { auditLoggerFactory, UserAuditView } from '../../helpers/audit-logger' |
48 | import { VideoImportModel } from '../../models/video/video-import' | ||
43 | 49 | ||
44 | const auditLogger = auditLoggerFactory('users') | 50 | const 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 | |||
72 | usersRouter.get('/me/videos/imports', | ||
73 | authenticate, | ||
74 | paginationValidator, | ||
75 | videoImportsSortValidator, | ||
76 | setDefaultSort, | ||
77 | setDefaultPagination, | ||
78 | asyncMiddleware(getUserVideoImports) | ||
79 | ) | ||
80 | |||
65 | usersRouter.get('/me/videos', | 81 | usersRouter.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 | ||
197 | async 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 | |||
181 | async function createUser (req: express.Request, res: express.Response) { | 209 | async 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({ |