diff options
author | Chocobozzz <me@florianbigard.com> | 2019-03-19 10:35:15 +0100 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2019-03-19 10:35:15 +0100 |
commit | dae86118ed5d4026d04acb9d0e36829b9ad8eb4e (patch) | |
tree | a5bf9c4487240bf75a9b328cad459a0587f90dea /server/controllers/api/users/me.ts | |
parent | e65c0c5b1fab9c3d93f51721b2458cf5cf471f20 (diff) | |
download | PeerTube-dae86118ed5d4026d04acb9d0e36829b9ad8eb4e.tar.gz PeerTube-dae86118ed5d4026d04acb9d0e36829b9ad8eb4e.tar.zst PeerTube-dae86118ed5d4026d04acb9d0e36829b9ad8eb4e.zip |
Cleanup express locals typings
Diffstat (limited to 'server/controllers/api/users/me.ts')
-rw-r--r-- | server/controllers/api/users/me.ts | 20 |
1 files changed, 10 insertions, 10 deletions
diff --git a/server/controllers/api/users/me.ts b/server/controllers/api/users/me.ts index d5e154869..3533499be 100644 --- a/server/controllers/api/users/me.ts +++ b/server/controllers/api/users/me.ts | |||
@@ -93,8 +93,8 @@ export { | |||
93 | 93 | ||
94 | // --------------------------------------------------------------------------- | 94 | // --------------------------------------------------------------------------- |
95 | 95 | ||
96 | async function getUserVideos (req: express.Request, res: express.Response, next: express.NextFunction) { | 96 | async function getUserVideos (req: express.Request, res: express.Response) { |
97 | const user = res.locals.oauth.token.User as UserModel | 97 | const user = res.locals.oauth.token.User |
98 | const resultList = await VideoModel.listUserVideosForApi( | 98 | const resultList = await VideoModel.listUserVideosForApi( |
99 | user.Account.id, | 99 | user.Account.id, |
100 | req.query.start as number, | 100 | req.query.start as number, |
@@ -111,8 +111,8 @@ async function getUserVideos (req: express.Request, res: express.Response, next: | |||
111 | return res.json(getFormattedObjects(resultList.data, resultList.total, { additionalAttributes })) | 111 | return res.json(getFormattedObjects(resultList.data, resultList.total, { additionalAttributes })) |
112 | } | 112 | } |
113 | 113 | ||
114 | async function getUserVideoImports (req: express.Request, res: express.Response, next: express.NextFunction) { | 114 | async function getUserVideoImports (req: express.Request, res: express.Response) { |
115 | const user = res.locals.oauth.token.User as UserModel | 115 | const user = res.locals.oauth.token.User |
116 | const resultList = await VideoImportModel.listUserVideoImportsForApi( | 116 | const resultList = await VideoImportModel.listUserVideoImportsForApi( |
117 | user.id, | 117 | user.id, |
118 | req.query.start as number, | 118 | req.query.start as number, |
@@ -123,14 +123,14 @@ async function getUserVideoImports (req: express.Request, res: express.Response, | |||
123 | return res.json(getFormattedObjects(resultList.data, resultList.total)) | 123 | return res.json(getFormattedObjects(resultList.data, resultList.total)) |
124 | } | 124 | } |
125 | 125 | ||
126 | async function getUserInformation (req: express.Request, res: express.Response, next: express.NextFunction) { | 126 | async function getUserInformation (req: express.Request, res: express.Response) { |
127 | // We did not load channels in res.locals.user | 127 | // We did not load channels in res.locals.user |
128 | const user = await UserModel.loadByUsernameAndPopulateChannels(res.locals.oauth.token.user.username) | 128 | const user = await UserModel.loadByUsernameAndPopulateChannels(res.locals.oauth.token.user.username) |
129 | 129 | ||
130 | return res.json(user.toFormattedJSON()) | 130 | return res.json(user.toFormattedJSON()) |
131 | } | 131 | } |
132 | 132 | ||
133 | async function getUserVideoQuotaUsed (req: express.Request, res: express.Response, next: express.NextFunction) { | 133 | async function getUserVideoQuotaUsed (req: express.Request, res: express.Response) { |
134 | // We did not load channels in res.locals.user | 134 | // We did not load channels in res.locals.user |
135 | const user = await UserModel.loadByUsernameAndPopulateChannels(res.locals.oauth.token.user.username) | 135 | const user = await UserModel.loadByUsernameAndPopulateChannels(res.locals.oauth.token.user.username) |
136 | const videoQuotaUsed = await UserModel.getOriginalVideoFileTotalFromUser(user) | 136 | const videoQuotaUsed = await UserModel.getOriginalVideoFileTotalFromUser(user) |
@@ -143,7 +143,7 @@ async function getUserVideoQuotaUsed (req: express.Request, res: express.Respons | |||
143 | return res.json(data) | 143 | return res.json(data) |
144 | } | 144 | } |
145 | 145 | ||
146 | async function getUserVideoRating (req: express.Request, res: express.Response, next: express.NextFunction) { | 146 | async function getUserVideoRating (req: express.Request, res: express.Response) { |
147 | const videoId = res.locals.video.id | 147 | const videoId = res.locals.video.id |
148 | const accountId = +res.locals.oauth.token.User.Account.id | 148 | const accountId = +res.locals.oauth.token.User.Account.id |
149 | 149 | ||
@@ -158,7 +158,7 @@ async function getUserVideoRating (req: express.Request, res: express.Response, | |||
158 | } | 158 | } |
159 | 159 | ||
160 | async function deleteMe (req: express.Request, res: express.Response) { | 160 | async function deleteMe (req: express.Request, res: express.Response) { |
161 | const user: UserModel = res.locals.oauth.token.User | 161 | const user = res.locals.oauth.token.User |
162 | 162 | ||
163 | await user.destroy() | 163 | await user.destroy() |
164 | 164 | ||
@@ -170,7 +170,7 @@ async function deleteMe (req: express.Request, res: express.Response) { | |||
170 | async function updateMe (req: express.Request, res: express.Response) { | 170 | async function updateMe (req: express.Request, res: express.Response) { |
171 | const body: UserUpdateMe = req.body | 171 | const body: UserUpdateMe = req.body |
172 | 172 | ||
173 | const user: UserModel = res.locals.oauth.token.user | 173 | const user = res.locals.oauth.token.user |
174 | const oldUserAuditView = new UserAuditView(user.toFormattedJSON()) | 174 | const oldUserAuditView = new UserAuditView(user.toFormattedJSON()) |
175 | 175 | ||
176 | if (body.password !== undefined) user.password = body.password | 176 | if (body.password !== undefined) user.password = body.password |
@@ -199,7 +199,7 @@ async function updateMe (req: express.Request, res: express.Response) { | |||
199 | 199 | ||
200 | async function updateMyAvatar (req: express.Request, res: express.Response) { | 200 | async function updateMyAvatar (req: express.Request, res: express.Response) { |
201 | const avatarPhysicalFile = req.files[ 'avatarfile' ][ 0 ] | 201 | const avatarPhysicalFile = req.files[ 'avatarfile' ][ 0 ] |
202 | const user: UserModel = res.locals.oauth.token.user | 202 | const user = res.locals.oauth.token.user |
203 | const oldUserAuditView = new UserAuditView(user.toFormattedJSON()) | 203 | const oldUserAuditView = new UserAuditView(user.toFormattedJSON()) |
204 | 204 | ||
205 | const userAccount = await AccountModel.load(user.Account.id) | 205 | const userAccount = await AccountModel.load(user.Account.id) |