diff options
author | Chocobozzz <me@florianbigard.com> | 2018-08-02 17:48:50 +0200 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2018-08-06 11:19:16 +0200 |
commit | ed31c059851a30bd5ba9999f8ecb3822d576b9f4 (patch) | |
tree | 7923ef7891ae9fd26965c3004bd75e736f0fedd0 /server/controllers/api | |
parent | 299474e8279675adb6c5ce140e7e39c6f3439453 (diff) | |
download | PeerTube-ed31c059851a30bd5ba9999f8ecb3822d576b9f4.tar.gz PeerTube-ed31c059851a30bd5ba9999f8ecb3822d576b9f4.tar.zst PeerTube-ed31c059851a30bd5ba9999f8ecb3822d576b9f4.zip |
Add ability to list video imports
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({ |