Browse Source

Cleanup express locals typings

Chocobozzz 8 months ago
parent
commit
dae86118ed
No account linked to committer's email address
45 changed files with 270 additions and 234 deletions
  1. 18
    18
      server/controllers/activitypub/client.ts
  2. 1
    8
      server/controllers/activitypub/inbox.ts
  3. 1
    1
      server/controllers/activitypub/outbox.ts
  4. 3
    4
      server/controllers/api/accounts.ts
  5. 1
    1
      server/controllers/api/index.ts
  6. 5
    5
      server/controllers/api/server/follows.ts
  7. 2
    3
      server/controllers/api/server/redundancy.ts
  8. 4
    6
      server/controllers/api/server/server-blocklist.ts
  9. 15
    15
      server/controllers/api/users/index.ts
  10. 10
    10
      server/controllers/api/users/me.ts
  11. 8
    9
      server/controllers/api/users/my-blocklist.ts
  12. 2
    2
      server/controllers/api/users/my-history.ts
  13. 5
    6
      server/controllers/api/users/my-notifications.ts
  14. 7
    8
      server/controllers/api/users/my-subscriptions.ts
  15. 1
    2
      server/controllers/api/users/my-video-playlists.ts
  16. 9
    10
      server/controllers/api/video-channel.ts
  17. 14
    16
      server/controllers/api/video-playlist.ts
  18. 4
    6
      server/controllers/api/videos/abuse.ts
  19. 3
    4
      server/controllers/api/videos/blacklist.ts
  20. 3
    4
      server/controllers/api/videos/captions.ts
  21. 11
    12
      server/controllers/api/videos/comment.ts
  22. 2
    2
      server/controllers/api/videos/import.ts
  23. 3
    3
      server/controllers/api/videos/index.ts
  24. 7
    9
      server/controllers/api/videos/ownership.ts
  25. 2
    3
      server/controllers/api/videos/rate.ts
  26. 1
    1
      server/controllers/api/videos/watching.ts
  27. 5
    7
      server/controllers/feeds.ts
  28. 2
    2
      server/controllers/services.ts
  29. 1
    1
      server/controllers/static.ts
  30. 2
    3
      server/controllers/webfinger.ts
  31. 2
    3
      server/helpers/express-utils.ts
  32. 1
    2
      server/middlewares/activitypub.ts
  33. 1
    2
      server/middlewares/user-right.ts
  34. 1
    2
      server/middlewares/validators/activitypub/activity.ts
  35. 3
    3
      server/middlewares/validators/blocklist.ts
  36. 3
    7
      server/middlewares/validators/redundancy.ts
  37. 1
    2
      server/middlewares/validators/user-subscriptions.ts
  38. 6
    6
      server/middlewares/validators/users.ts
  39. 1
    2
      server/middlewares/validators/videos/video-blacklist.ts
  40. 8
    9
      server/middlewares/validators/videos/video-playlists.ts
  41. 1
    2
      server/middlewares/validators/videos/video-shares.ts
  42. 1
    2
      server/middlewares/validators/videos/video-watch.ts
  43. 6
    6
      server/middlewares/validators/videos/videos.ts
  44. 82
    0
      server/typings/express.ts
  45. 1
    5
      tsconfig.json

+ 18
- 18
server/controllers/activitypub/client.ts View File

@@ -169,27 +169,27 @@ export {
169 169
 // ---------------------------------------------------------------------------
170 170
 
171 171
 function accountController (req: express.Request, res: express.Response) {
172
-  const account: AccountModel = res.locals.account
172
+  const account = res.locals.account
173 173
 
174 174
   return activityPubResponse(activityPubContextify(account.toActivityPubObject()), res)
175 175
 }
176 176
 
177 177
 async function accountFollowersController (req: express.Request, res: express.Response) {
178
-  const account: AccountModel = res.locals.account
178
+  const account = res.locals.account
179 179
   const activityPubResult = await actorFollowers(req, account.Actor)
180 180
 
181 181
   return activityPubResponse(activityPubContextify(activityPubResult), res)
182 182
 }
183 183
 
184 184
 async function accountFollowingController (req: express.Request, res: express.Response) {
185
-  const account: AccountModel = res.locals.account
185
+  const account = res.locals.account
186 186
   const activityPubResult = await actorFollowing(req, account.Actor)
187 187
 
188 188
   return activityPubResponse(activityPubContextify(activityPubResult), res)
189 189
 }
190 190
 
191 191
 async function accountPlaylistsController (req: express.Request, res: express.Response) {
192
-  const account: AccountModel = res.locals.account
192
+  const account = res.locals.account
193 193
   const activityPubResult = await actorPlaylists(req, account)
194 194
 
195 195
   return activityPubResponse(activityPubContextify(activityPubResult), res)
@@ -197,7 +197,7 @@ async function accountPlaylistsController (req: express.Request, res: express.Re
197 197
 
198 198
 function getAccountVideoRate (rateType: VideoRateType) {
199 199
   return (req: express.Request, res: express.Response) => {
200
-    const accountVideoRate: AccountVideoRateModel = res.locals.accountVideoRate
200
+    const accountVideoRate = res.locals.accountVideoRate
201 201
 
202 202
     const byActor = accountVideoRate.Account.Actor
203 203
     const url = getRateUrl(rateType, byActor, accountVideoRate.Video)
@@ -211,7 +211,7 @@ function getAccountVideoRate (rateType: VideoRateType) {
211 211
 
212 212
 async function videoController (req: express.Request, res: express.Response) {
213 213
   // We need more attributes
214
-  const video: VideoModel = await VideoModel.loadForGetAPI(res.locals.video.id)
214
+  const video = await VideoModel.loadForGetAPI(res.locals.video.id)
215 215
 
216 216
   if (video.url.startsWith(CONFIG.WEBSERVER.URL) === false) return res.redirect(video.url)
217 217
 
@@ -230,7 +230,7 @@ async function videoController (req: express.Request, res: express.Response) {
230 230
 }
231 231
 
232 232
 async function videoAnnounceController (req: express.Request, res: express.Response) {
233
-  const share = res.locals.videoShare as VideoShareModel
233
+  const share = res.locals.videoShare
234 234
 
235 235
   if (share.url.startsWith(CONFIG.WEBSERVER.URL) === false) return res.redirect(share.url)
236 236
 
@@ -240,7 +240,7 @@ async function videoAnnounceController (req: express.Request, res: express.Respo
240 240
 }
241 241
 
242 242
 async function videoAnnouncesController (req: express.Request, res: express.Response) {
243
-  const video: VideoModel = res.locals.video
243
+  const video = res.locals.video
244 244
 
245 245
   const handler = async (start: number, count: number) => {
246 246
     const result = await VideoShareModel.listAndCountByVideoId(video.id, start, count)
@@ -255,21 +255,21 @@ async function videoAnnouncesController (req: express.Request, res: express.Resp
255 255
 }
256 256
 
257 257
 async function videoLikesController (req: express.Request, res: express.Response) {
258
-  const video: VideoModel = res.locals.video
258
+  const video = res.locals.video
259 259
   const json = await videoRates(req, 'like', video, getVideoLikesActivityPubUrl(video))
260 260
 
261 261
   return activityPubResponse(activityPubContextify(json), res)
262 262
 }
263 263
 
264 264
 async function videoDislikesController (req: express.Request, res: express.Response) {
265
-  const video: VideoModel = res.locals.video
265
+  const video = res.locals.video
266 266
   const json = await videoRates(req, 'dislike', video, getVideoDislikesActivityPubUrl(video))
267 267
 
268 268
   return activityPubResponse(activityPubContextify(json), res)
269 269
 }
270 270
 
271 271
 async function videoCommentsController (req: express.Request, res: express.Response) {
272
-  const video: VideoModel = res.locals.video
272
+  const video = res.locals.video
273 273
 
274 274
   const handler = async (start: number, count: number) => {
275 275
     const result = await VideoCommentModel.listAndCountByVideoId(video.id, start, count)
@@ -284,27 +284,27 @@ async function videoCommentsController (req: express.Request, res: express.Respo
284 284
 }
285 285
 
286 286
 async function videoChannelController (req: express.Request, res: express.Response) {
287
-  const videoChannel: VideoChannelModel = res.locals.videoChannel
287
+  const videoChannel = res.locals.videoChannel
288 288
 
289 289
   return activityPubResponse(activityPubContextify(videoChannel.toActivityPubObject()), res)
290 290
 }
291 291
 
292 292
 async function videoChannelFollowersController (req: express.Request, res: express.Response) {
293
-  const videoChannel: VideoChannelModel = res.locals.videoChannel
293
+  const videoChannel = res.locals.videoChannel
294 294
   const activityPubResult = await actorFollowers(req, videoChannel.Actor)
295 295
 
296 296
   return activityPubResponse(activityPubContextify(activityPubResult), res)
297 297
 }
298 298
 
299 299
 async function videoChannelFollowingController (req: express.Request, res: express.Response) {
300
-  const videoChannel: VideoChannelModel = res.locals.videoChannel
300
+  const videoChannel = res.locals.videoChannel
301 301
   const activityPubResult = await actorFollowing(req, videoChannel.Actor)
302 302
 
303 303
   return activityPubResponse(activityPubContextify(activityPubResult), res)
304 304
 }
305 305
 
306 306
 async function videoCommentController (req: express.Request, res: express.Response) {
307
-  const videoComment: VideoCommentModel = res.locals.videoComment
307
+  const videoComment = res.locals.videoComment
308 308
 
309 309
   if (videoComment.url.startsWith(CONFIG.WEBSERVER.URL) === false) return res.redirect(videoComment.url)
310 310
 
@@ -323,7 +323,7 @@ async function videoCommentController (req: express.Request, res: express.Respon
323 323
 }
324 324
 
325 325
 async function videoRedundancyController (req: express.Request, res: express.Response) {
326
-  const videoRedundancy: VideoRedundancyModel = res.locals.videoRedundancy
326
+  const videoRedundancy = res.locals.videoRedundancy
327 327
   if (videoRedundancy.url.startsWith(CONFIG.WEBSERVER.URL) === false) return res.redirect(videoRedundancy.url)
328 328
 
329 329
   const serverActor = await getServerActor()
@@ -340,7 +340,7 @@ async function videoRedundancyController (req: express.Request, res: express.Res
340 340
 }
341 341
 
342 342
 async function videoPlaylistController (req: express.Request, res: express.Response) {
343
-  const playlist: VideoPlaylistModel = res.locals.videoPlaylist
343
+  const playlist = res.locals.videoPlaylist
344 344
 
345 345
   // We need more attributes
346 346
   playlist.OwnerAccount = await AccountModel.load(playlist.ownerAccountId)
@@ -353,7 +353,7 @@ async function videoPlaylistController (req: express.Request, res: express.Respo
353 353
 }
354 354
 
355 355
 async function videoPlaylistElementController (req: express.Request, res: express.Response) {
356
-  const videoPlaylistElement: VideoPlaylistElementModel = res.locals.videoPlaylistElement
356
+  const videoPlaylistElement = res.locals.videoPlaylistElement
357 357
 
358 358
   const json = videoPlaylistElement.toActivityPubObject()
359 359
   return activityPubResponse(activityPubContextify(json), res)

+ 1
- 8
server/controllers/activitypub/inbox.ts View File

@@ -5,8 +5,6 @@ import { logger } from '../../helpers/logger'
5 5
 import { processActivities } from '../../lib/activitypub/process/process'
6 6
 import { asyncMiddleware, checkSignature, localAccountValidator, localVideoChannelValidator, signatureValidator } from '../../middlewares'
7 7
 import { activityPubValidator } from '../../middlewares/validators/activitypub/activity'
8
-import { VideoChannelModel } from '../../models/video/video-channel'
9
-import { AccountModel } from '../../models/account/account'
10 8
 import { queue } from 'async'
11 9
 import { ActorModel } from '../../models/activitypub/actor'
12 10
 
@@ -66,12 +64,7 @@ function inboxController (req: express.Request, res: express.Response) {
66 64
   activities = activities.filter(a => isActivityValid(a))
67 65
   logger.debug('We keep %d activities.', activities.length, { activities })
68 66
 
69
-  let accountOrChannel: VideoChannelModel | AccountModel
70
-  if (res.locals.account) {
71
-    accountOrChannel = res.locals.account
72
-  } else if (res.locals.videoChannel) {
73
-    accountOrChannel = res.locals.videoChannel
74
-  }
67
+  const accountOrChannel = res.locals.account || res.locals.videoChannel
75 68
 
76 69
   logger.info('Receiving inbox requests for %d activities by %s.', activities.length, res.locals.signature.actor.url)
77 70
 

+ 1
- 1
server/controllers/activitypub/outbox.ts View File

@@ -33,7 +33,7 @@ export {
33 33
 // ---------------------------------------------------------------------------
34 34
 
35 35
 async function outboxController (req: express.Request, res: express.Response) {
36
-  const accountOrVideoChannel: AccountModel | VideoChannelModel = res.locals.account || res.locals.videoChannel
36
+  const accountOrVideoChannel = res.locals.account || res.locals.videoChannel
37 37
   const actor = accountOrVideoChannel.Actor
38 38
   const actorOutboxUrl = actor.url + '/outbox'
39 39
 

+ 3
- 4
server/controllers/api/accounts.ts View File

@@ -17,7 +17,6 @@ import { VideoChannelModel } from '../../models/video/video-channel'
17 17
 import { JobQueue } from '../../lib/job-queue'
18 18
 import { logger } from '../../helpers/logger'
19 19
 import { VideoPlaylistModel } from '../../models/video/video-playlist'
20
-import { UserModel } from '../../models/account/user'
21 20
 import { commonVideoPlaylistFiltersValidator } from '../../middlewares/validators/videos/video-playlists'
22 21
 
23 22
 const accountsRouter = express.Router()
@@ -71,7 +70,7 @@ export {
71 70
 // ---------------------------------------------------------------------------
72 71
 
73 72
 function getAccount (req: express.Request, res: express.Response) {
74
-  const account: AccountModel = res.locals.account
73
+  const account = res.locals.account
75 74
 
76 75
   if (account.isOutdated()) {
77 76
     JobQueue.Instance.createJob({ type: 'activitypub-refresher', payload: { type: 'actor', url: account.Actor.url } })
@@ -98,7 +97,7 @@ async function listAccountPlaylists (req: express.Request, res: express.Response
98 97
 
99 98
   // Allow users to see their private/unlisted video playlists
100 99
   let privateAndUnlisted = false
101
-  if (res.locals.oauth && (res.locals.oauth.token.User as UserModel).Account.id === res.locals.account.id) {
100
+  if (res.locals.oauth && res.locals.oauth.token.User.Account.id === res.locals.account.id) {
102 101
     privateAndUnlisted = true
103 102
   }
104 103
 
@@ -116,7 +115,7 @@ async function listAccountPlaylists (req: express.Request, res: express.Response
116 115
 }
117 116
 
118 117
 async function listAccountVideos (req: express.Request, res: express.Response) {
119
-  const account: AccountModel = res.locals.account
118
+  const account = res.locals.account
120 119
   const followerActorId = isUserAbleToSearchRemoteURI(res) ? null : undefined
121 120
 
122 121
   const resultList = await VideoModel.listForApi({

+ 1
- 1
server/controllers/api/index.ts View File

@@ -41,6 +41,6 @@ export { apiRouter }
41 41
 
42 42
 // ---------------------------------------------------------------------------
43 43
 
44
-function pong (req: express.Request, res: express.Response, next: express.NextFunction) {
44
+function pong (req: express.Request, res: express.Response) {
45 45
   return res.send('pong').status(200).end()
46 46
 }

+ 5
- 5
server/controllers/api/server/follows.ts View File

@@ -59,7 +59,7 @@ export {
59 59
 
60 60
 // ---------------------------------------------------------------------------
61 61
 
62
-async function listFollowing (req: express.Request, res: express.Response, next: express.NextFunction) {
62
+async function listFollowing (req: express.Request, res: express.Response) {
63 63
   const serverActor = await getServerActor()
64 64
   const resultList = await ActorFollowModel.listFollowingForApi(
65 65
     serverActor.id,
@@ -72,7 +72,7 @@ async function listFollowing (req: express.Request, res: express.Response, next:
72 72
   return res.json(getFormattedObjects(resultList.data, resultList.total))
73 73
 }
74 74
 
75
-async function listFollowers (req: express.Request, res: express.Response, next: express.NextFunction) {
75
+async function listFollowers (req: express.Request, res: express.Response) {
76 76
   const serverActor = await getServerActor()
77 77
   const resultList = await ActorFollowModel.listFollowersForApi(
78 78
     serverActor.id,
@@ -85,7 +85,7 @@ async function listFollowers (req: express.Request, res: express.Response, next:
85 85
   return res.json(getFormattedObjects(resultList.data, resultList.total))
86 86
 }
87 87
 
88
-async function followInstance (req: express.Request, res: express.Response, next: express.NextFunction) {
88
+async function followInstance (req: express.Request, res: express.Response) {
89 89
   const hosts = req.body.hosts as string[]
90 90
   const follower = await getServerActor()
91 91
 
@@ -103,8 +103,8 @@ async function followInstance (req: express.Request, res: express.Response, next
103 103
   return res.status(204).end()
104 104
 }
105 105
 
106
-async function removeFollow (req: express.Request, res: express.Response, next: express.NextFunction) {
107
-  const follow: ActorFollowModel = res.locals.follow
106
+async function removeFollow (req: express.Request, res: express.Response) {
107
+  const follow = res.locals.follow
108 108
 
109 109
   await sequelizeTypescript.transaction(async t => {
110 110
     if (follow.state === 'accepted') await sendUndoFollow(follow, t)

+ 2
- 3
server/controllers/api/server/redundancy.ts View File

@@ -2,7 +2,6 @@ import * as express from 'express'
2 2
 import { UserRight } from '../../../../shared/models/users'
3 3
 import { asyncMiddleware, authenticate, ensureUserHasRight } from '../../../middlewares'
4 4
 import { updateServerRedundancyValidator } from '../../../middlewares/validators/redundancy'
5
-import { ServerModel } from '../../../models/server/server'
6 5
 import { removeRedundancyOf } from '../../../lib/redundancy'
7 6
 import { logger } from '../../../helpers/logger'
8 7
 
@@ -23,8 +22,8 @@ export {
23 22
 
24 23
 // ---------------------------------------------------------------------------
25 24
 
26
-async function updateRedundancy (req: express.Request, res: express.Response, next: express.NextFunction) {
27
-  const server = res.locals.server as ServerModel
25
+async function updateRedundancy (req: express.Request, res: express.Response) {
26
+  const server = res.locals.server
28 27
 
29 28
   server.redundancyAllowed = req.body.redundancyAllowed
30 29
 

+ 4
- 6
server/controllers/api/server/server-blocklist.ts View File

@@ -18,11 +18,9 @@ import {
18 18
   unblockAccountByServerValidator,
19 19
   unblockServerByServerValidator
20 20
 } from '../../../middlewares/validators'
21
-import { AccountModel } from '../../../models/account/account'
22 21
 import { AccountBlocklistModel } from '../../../models/account/account-blocklist'
23 22
 import { addAccountInBlocklist, addServerInBlocklist, removeAccountFromBlocklist, removeServerFromBlocklist } from '../../../lib/blocklist'
24 23
 import { ServerBlocklistModel } from '../../../models/server/server-blocklist'
25
-import { ServerModel } from '../../../models/server/server'
26 24
 import { UserRight } from '../../../../shared/models/users'
27 25
 
28 26
 const serverBlocklistRouter = express.Router()
@@ -91,7 +89,7 @@ async function listBlockedAccounts (req: express.Request, res: express.Response)
91 89
 
92 90
 async function blockAccount (req: express.Request, res: express.Response) {
93 91
   const serverActor = await getServerActor()
94
-  const accountToBlock: AccountModel = res.locals.account
92
+  const accountToBlock = res.locals.account
95 93
 
96 94
   await addAccountInBlocklist(serverActor.Account.id, accountToBlock.id)
97 95
 
@@ -99,7 +97,7 @@ async function blockAccount (req: express.Request, res: express.Response) {
99 97
 }
100 98
 
101 99
 async function unblockAccount (req: express.Request, res: express.Response) {
102
-  const accountBlock: AccountBlocklistModel = res.locals.accountBlock
100
+  const accountBlock = res.locals.accountBlock
103 101
 
104 102
   await removeAccountFromBlocklist(accountBlock)
105 103
 
@@ -116,7 +114,7 @@ async function listBlockedServers (req: express.Request, res: express.Response)
116 114
 
117 115
 async function blockServer (req: express.Request, res: express.Response) {
118 116
   const serverActor = await getServerActor()
119
-  const serverToBlock: ServerModel = res.locals.server
117
+  const serverToBlock = res.locals.server
120 118
 
121 119
   await addServerInBlocklist(serverActor.Account.id, serverToBlock.id)
122 120
 
@@ -124,7 +122,7 @@ async function blockServer (req: express.Request, res: express.Response) {
124 122
 }
125 123
 
126 124
 async function unblockServer (req: express.Request, res: express.Response) {
127
-  const serverBlock: ServerBlocklistModel = res.locals.serverBlock
125
+  const serverBlock = res.locals.serverBlock
128 126
 
129 127
   await removeServerFromBlocklist(serverBlock)
130 128
 

+ 15
- 15
server/controllers/api/users/index.ts View File

@@ -221,8 +221,8 @@ async function registerUser (req: express.Request, res: express.Response) {
221 221
   return res.type('json').status(204).end()
222 222
 }
223 223
 
224
-async function unblockUser (req: express.Request, res: express.Response, next: express.NextFunction) {
225
-  const user: UserModel = res.locals.user
224
+async function unblockUser (req: express.Request, res: express.Response) {
225
+  const user = res.locals.user
226 226
 
227 227
   await changeUserBlock(res, user, false)
228 228
 
@@ -230,7 +230,7 @@ async function unblockUser (req: express.Request, res: express.Response, next: e
230 230
 }
231 231
 
232 232
 async function blockUser (req: express.Request, res: express.Response) {
233
-  const user: UserModel = res.locals.user
233
+  const user = res.locals.user
234 234
   const reason = req.body.reason
235 235
 
236 236
   await changeUserBlock(res, user, true, reason)
@@ -239,7 +239,7 @@ async function blockUser (req: express.Request, res: express.Response) {
239 239
 }
240 240
 
241 241
 function getUser (req: express.Request, res: express.Response) {
242
-  return res.json((res.locals.user as UserModel).toFormattedJSON())
242
+  return res.json(res.locals.user.toFormattedJSON())
243 243
 }
244 244
 
245 245
 async function autocompleteUsers (req: express.Request, res: express.Response) {
@@ -255,7 +255,7 @@ async function listUsers (req: express.Request, res: express.Response) {
255 255
 }
256 256
 
257 257
 async function removeUser (req: express.Request, res: express.Response) {
258
-  const user: UserModel = res.locals.user
258
+  const user = res.locals.user
259 259
 
260 260
   await user.destroy()
261 261
 
@@ -266,7 +266,7 @@ async function removeUser (req: express.Request, res: express.Response) {
266 266
 
267 267
 async function updateUser (req: express.Request, res: express.Response) {
268 268
   const body: UserUpdate = req.body
269
-  const userToUpdate = res.locals.user as UserModel
269
+  const userToUpdate = res.locals.user
270 270
   const oldUserAuditView = new UserAuditView(userToUpdate.toFormattedJSON())
271 271
   const roleChanged = body.role !== undefined && body.role !== userToUpdate.role
272 272
 
@@ -289,8 +289,8 @@ async function updateUser (req: express.Request, res: express.Response) {
289 289
   return res.sendStatus(204)
290 290
 }
291 291
 
292
-async function askResetUserPassword (req: express.Request, res: express.Response, next: express.NextFunction) {
293
-  const user = res.locals.user as UserModel
292
+async function askResetUserPassword (req: express.Request, res: express.Response) {
293
+  const user = res.locals.user
294 294
 
295 295
   const verificationString = await Redis.Instance.setResetPasswordVerificationString(user.id)
296 296
   const url = CONFIG.WEBSERVER.URL + '/reset-password?userId=' + user.id + '&verificationString=' + verificationString
@@ -299,8 +299,8 @@ async function askResetUserPassword (req: express.Request, res: express.Response
299 299
   return res.status(204).end()
300 300
 }
301 301
 
302
-async function resetUserPassword (req: express.Request, res: express.Response, next: express.NextFunction) {
303
-  const user = res.locals.user as UserModel
302
+async function resetUserPassword (req: express.Request, res: express.Response) {
303
+  const user = res.locals.user
304 304
   user.password = req.body.password
305 305
 
306 306
   await user.save()
@@ -315,16 +315,16 @@ async function sendVerifyUserEmail (user: UserModel) {
315 315
   return
316 316
 }
317 317
 
318
-async function askSendVerifyUserEmail (req: express.Request, res: express.Response, next: express.NextFunction) {
319
-  const user = res.locals.user as UserModel
318
+async function askSendVerifyUserEmail (req: express.Request, res: express.Response) {
319
+  const user = res.locals.user
320 320
 
321 321
   await sendVerifyUserEmail(user)
322 322
 
323 323
   return res.status(204).end()
324 324
 }
325 325
 
326
-async function verifyUserEmail (req: express.Request, res: express.Response, next: express.NextFunction) {
327
-  const user = res.locals.user as UserModel
326
+async function verifyUserEmail (req: express.Request, res: express.Response) {
327
+  const user = res.locals.user
328 328
   user.emailVerified = true
329 329
 
330 330
   await user.save()
@@ -332,7 +332,7 @@ async function verifyUserEmail (req: express.Request, res: express.Response, nex
332 332
   return res.status(204).end()
333 333
 }
334 334
 
335
-function success (req: express.Request, res: express.Response, next: express.NextFunction) {
335
+function success (req: express.Request, res: express.Response) {
336 336
   res.end()
337 337
 }
338 338
 

+ 10
- 10
server/controllers/api/users/me.ts View File

@@ -93,8 +93,8 @@ export {
93 93
 
94 94
 // ---------------------------------------------------------------------------
95 95
 
96
-async function getUserVideos (req: express.Request, res: express.Response, next: express.NextFunction) {
97
-  const user = res.locals.oauth.token.User as UserModel
96
+async function getUserVideos (req: express.Request, res: express.Response) {
97
+  const user = res.locals.oauth.token.User
98 98
   const resultList = await VideoModel.listUserVideosForApi(
99 99
     user.Account.id,
100 100
     req.query.start as number,
@@ -111,8 +111,8 @@ async function getUserVideos (req: express.Request, res: express.Response, next:
111 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) {
115
-  const user = res.locals.oauth.token.User as UserModel
114
+async function getUserVideoImports (req: express.Request, res: express.Response) {
115
+  const user = res.locals.oauth.token.User
116 116
   const resultList = await VideoImportModel.listUserVideoImportsForApi(
117 117
     user.id,
118 118
     req.query.start as number,
@@ -123,14 +123,14 @@ async function getUserVideoImports (req: express.Request, res: express.Response,
123 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 127
   // We did not load channels in res.locals.user
128 128
   const user = await UserModel.loadByUsernameAndPopulateChannels(res.locals.oauth.token.user.username)
129 129
 
130 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 134
   // We did not load channels in res.locals.user
135 135
   const user = await UserModel.loadByUsernameAndPopulateChannels(res.locals.oauth.token.user.username)
136 136
   const videoQuotaUsed = await UserModel.getOriginalVideoFileTotalFromUser(user)
@@ -143,7 +143,7 @@ async function getUserVideoQuotaUsed (req: express.Request, res: express.Respons
143 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 147
   const videoId = res.locals.video.id
148 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 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 163
   await user.destroy()
164 164
 
@@ -170,7 +170,7 @@ async function deleteMe (req: express.Request, res: express.Response) {
170 170
 async function updateMe (req: express.Request, res: express.Response) {
171 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 174
   const oldUserAuditView = new UserAuditView(user.toFormattedJSON())
175 175
 
176 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 200
 async function updateMyAvatar (req: express.Request, res: express.Response) {
201 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 203
   const oldUserAuditView = new UserAuditView(user.toFormattedJSON())
204 204
 
205 205
   const userAccount = await AccountModel.load(user.Account.id)

+ 8
- 9
server/controllers/api/users/my-blocklist.ts View File

@@ -17,7 +17,6 @@ import {
17 17
   serversBlocklistSortValidator,
18 18
   unblockServerByAccountValidator
19 19
 } from '../../../middlewares/validators'
20
-import { UserModel } from '../../../models/account/user'
21 20
 import { AccountModel } from '../../../models/account/account'
22 21
 import { AccountBlocklistModel } from '../../../models/account/account-blocklist'
23 22
 import { addAccountInBlocklist, addServerInBlocklist, removeAccountFromBlocklist, removeServerFromBlocklist } from '../../../lib/blocklist'
@@ -75,7 +74,7 @@ export {
75 74
 // ---------------------------------------------------------------------------
76 75
 
77 76
 async function listBlockedAccounts (req: express.Request, res: express.Response) {
78
-  const user: UserModel = res.locals.oauth.token.User
77
+  const user = res.locals.oauth.token.User
79 78
 
80 79
   const resultList = await AccountBlocklistModel.listForApi(user.Account.id, req.query.start, req.query.count, req.query.sort)
81 80
 
@@ -83,8 +82,8 @@ async function listBlockedAccounts (req: express.Request, res: express.Response)
83 82
 }
84 83
 
85 84
 async function blockAccount (req: express.Request, res: express.Response) {
86
-  const user: UserModel = res.locals.oauth.token.User
87
-  const accountToBlock: AccountModel = res.locals.account
85
+  const user = res.locals.oauth.token.User
86
+  const accountToBlock  = res.locals.account
88 87
 
89 88
   await addAccountInBlocklist(user.Account.id, accountToBlock.id)
90 89
 
@@ -92,7 +91,7 @@ async function blockAccount (req: express.Request, res: express.Response) {
92 91
 }
93 92
 
94 93
 async function unblockAccount (req: express.Request, res: express.Response) {
95
-  const accountBlock: AccountBlocklistModel = res.locals.accountBlock
94
+  const accountBlock = res.locals.accountBlock
96 95
 
97 96
   await removeAccountFromBlocklist(accountBlock)
98 97
 
@@ -100,7 +99,7 @@ async function unblockAccount (req: express.Request, res: express.Response) {
100 99
 }
101 100
 
102 101
 async function listBlockedServers (req: express.Request, res: express.Response) {
103
-  const user: UserModel = res.locals.oauth.token.User
102
+  const user = res.locals.oauth.token.User
104 103
 
105 104
   const resultList = await ServerBlocklistModel.listForApi(user.Account.id, req.query.start, req.query.count, req.query.sort)
106 105
 
@@ -108,8 +107,8 @@ async function listBlockedServers (req: express.Request, res: express.Response)
108 107
 }
109 108
 
110 109
 async function blockServer (req: express.Request, res: express.Response) {
111
-  const user: UserModel = res.locals.oauth.token.User
112
-  const serverToBlock: ServerModel = res.locals.server
110
+  const user = res.locals.oauth.token.User
111
+  const serverToBlock = res.locals.server
113 112
 
114 113
   await addServerInBlocklist(user.Account.id, serverToBlock.id)
115 114
 
@@ -117,7 +116,7 @@ async function blockServer (req: express.Request, res: express.Response) {
117 116
 }
118 117
 
119 118
 async function unblockServer (req: express.Request, res: express.Response) {
120
-  const serverBlock: ServerBlocklistModel = res.locals.serverBlock
119
+  const serverBlock = res.locals.serverBlock
121 120
 
122 121
   await removeServerFromBlocklist(serverBlock)
123 122
 

+ 2
- 2
server/controllers/api/users/my-history.ts View File

@@ -36,7 +36,7 @@ export {
36 36
 // ---------------------------------------------------------------------------
37 37
 
38 38
 async function listMyVideosHistory (req: express.Request, res: express.Response) {
39
-  const user: UserModel = res.locals.oauth.token.User
39
+  const user = res.locals.oauth.token.User
40 40
 
41 41
   const resultList = await UserVideoHistoryModel.listForApi(user, req.query.start, req.query.count)
42 42
 
@@ -44,7 +44,7 @@ async function listMyVideosHistory (req: express.Request, res: express.Response)
44 44
 }
45 45
 
46 46
 async function removeUserHistory (req: express.Request, res: express.Response) {
47
-  const user: UserModel = res.locals.oauth.token.User
47
+  const user = res.locals.oauth.token.User
48 48
   const beforeDate = req.body.beforeDate || null
49 49
 
50 50
   await sequelizeTypescript.transaction(t => {

+ 5
- 6
server/controllers/api/users/my-notifications.ts View File

@@ -9,7 +9,6 @@ import {
9 9
   setDefaultSort,
10 10
   userNotificationsSortValidator
11 11
 } from '../../../middlewares'
12
-import { UserModel } from '../../../models/account/user'
13 12
 import { getFormattedObjects } from '../../../helpers/utils'
14 13
 import { UserNotificationModel } from '../../../models/account/user-notification'
15 14
 import { meRouter } from './me'
@@ -57,8 +56,8 @@ export {
57 56
 // ---------------------------------------------------------------------------
58 57
 
59 58
 async function updateNotificationSettings (req: express.Request, res: express.Response) {
60
-  const user: UserModel = res.locals.oauth.token.User
61
-  const body = req.body
59
+  const user = res.locals.oauth.token.User
60
+  const body = req.body as UserNotificationSetting
62 61
 
63 62
   const query = {
64 63
     where: {
@@ -84,7 +83,7 @@ async function updateNotificationSettings (req: express.Request, res: express.Re
84 83
 }
85 84
 
86 85
 async function listUserNotifications (req: express.Request, res: express.Response) {
87
-  const user: UserModel = res.locals.oauth.token.User
86
+  const user = res.locals.oauth.token.User
88 87
 
89 88
   const resultList = await UserNotificationModel.listForApi(user.id, req.query.start, req.query.count, req.query.sort, req.query.unread)
90 89
 
@@ -92,7 +91,7 @@ async function listUserNotifications (req: express.Request, res: express.Respons
92 91
 }
93 92
 
94 93
 async function markAsReadUserNotifications (req: express.Request, res: express.Response) {
95
-  const user: UserModel = res.locals.oauth.token.User
94
+  const user = res.locals.oauth.token.User
96 95
 
97 96
   await UserNotificationModel.markAsRead(user.id, req.body.ids)
98 97
 
@@ -100,7 +99,7 @@ async function markAsReadUserNotifications (req: express.Request, res: express.R
100 99
 }
101 100
 
102 101
 async function markAsReadAllUserNotifications (req: express.Request, res: express.Response) {
103
-  const user: UserModel = res.locals.oauth.token.User
102
+  const user = res.locals.oauth.token.User
104 103
 
105 104
   await UserNotificationModel.markAllAsRead(user.id)
106 105
 

+ 7
- 8
server/controllers/api/users/my-subscriptions.ts View File

@@ -14,7 +14,6 @@ import {
14 14
   userSubscriptionGetValidator
15 15
 } from '../../../middlewares'
16 16
 import { areSubscriptionsExistValidator, userSubscriptionsSortValidator, videosSortValidator } from '../../../middlewares/validators'
17
-import { UserModel } from '../../../models/account/user'
18 17
 import { VideoModel } from '../../../models/video/video'
19 18
 import { buildNSFWFilter } from '../../../helpers/express-utils'
20 19
 import { VideoFilter } from '../../../../shared/models/videos/video-query.type'
@@ -77,7 +76,7 @@ export {
77 76
 
78 77
 async function areSubscriptionsExist (req: express.Request, res: express.Response) {
79 78
   const uris = req.query.uris as string[]
80
-  const user = res.locals.oauth.token.User as UserModel
79
+  const user = res.locals.oauth.token.User
81 80
 
82 81
   const handles = uris.map(u => {
83 82
     let [ name, host ] = u.split('@')
@@ -107,7 +106,7 @@ async function areSubscriptionsExist (req: express.Request, res: express.Respons
107 106
 }
108 107
 
109 108
 async function addUserSubscription (req: express.Request, res: express.Response) {
110
-  const user = res.locals.oauth.token.User as UserModel
109
+  const user = res.locals.oauth.token.User
111 110
   const [ name, host ] = req.body.uri.split('@')
112 111
 
113 112
   const payload = {
@@ -123,13 +122,13 @@ async function addUserSubscription (req: express.Request, res: express.Response)
123 122
 }
124 123
 
125 124
 function getUserSubscription (req: express.Request, res: express.Response) {
126
-  const subscription: ActorFollowModel = res.locals.subscription
125
+  const subscription = res.locals.subscription
127 126
 
128 127
   return res.json(subscription.ActorFollowing.VideoChannel.toFormattedJSON())
129 128
 }
130 129
 
131 130
 async function deleteUserSubscription (req: express.Request, res: express.Response) {
132
-  const subscription: ActorFollowModel = res.locals.subscription
131
+  const subscription = res.locals.subscription
133 132
 
134 133
   await sequelizeTypescript.transaction(async t => {
135 134
     return subscription.destroy({ transaction: t })
@@ -139,7 +138,7 @@ async function deleteUserSubscription (req: express.Request, res: express.Respon
139 138
 }
140 139
 
141 140
 async function getUserSubscriptions (req: express.Request, res: express.Response) {
142
-  const user = res.locals.oauth.token.User as UserModel
141
+  const user = res.locals.oauth.token.User
143 142
   const actorId = user.Account.Actor.id
144 143
 
145 144
   const resultList = await ActorFollowModel.listSubscriptionsForApi(actorId, req.query.start, req.query.count, req.query.sort)
@@ -147,8 +146,8 @@ async function getUserSubscriptions (req: express.Request, res: express.Response
147 146
   return res.json(getFormattedObjects(resultList.data, resultList.total))
148 147
 }
149 148
 
150
-async function getUserSubscriptionVideos (req: express.Request, res: express.Response, next: express.NextFunction) {
151
-  const user = res.locals.oauth.token.User as UserModel
149
+async function getUserSubscriptionVideos (req: express.Request, res: express.Response) {
150
+  const user = res.locals.oauth.token.User
152 151
   const resultList = await VideoModel.listForApi({
153 152
     start: req.query.start,
154 153
     count: req.query.count,

+ 1
- 2
server/controllers/api/users/my-video-playlists.ts View File

@@ -1,6 +1,5 @@
1 1
 import * as express from 'express'
2 2
 import { asyncMiddleware, authenticate } from '../../../middlewares'
3
-import { UserModel } from '../../../models/account/user'
4 3
 import { doVideosInPlaylistExistValidator } from '../../../middlewares/validators/videos/video-playlists'
5 4
 import { VideoPlaylistModel } from '../../../models/video/video-playlist'
6 5
 import { VideoExistInPlaylist } from '../../../../shared/models/videos/playlist/video-exist-in-playlist.model'
@@ -23,7 +22,7 @@ export {
23 22
 
24 23
 async function doVideosInPlaylistExist (req: express.Request, res: express.Response) {
25 24
   const videoIds = req.query.videoIds.map(i => parseInt(i + '', 10))
26
-  const user = res.locals.oauth.token.User as UserModel
25
+  const user = res.locals.oauth.token.User
27 26
 
28 27
   const results = await VideoPlaylistModel.listPlaylistIdsOf(user.Account.id, videoIds)
29 28
 

+ 9
- 10
server/controllers/api/video-channel.ts View File

@@ -30,7 +30,6 @@ import { updateAvatarValidator } from '../../middlewares/validators/avatar'
30 30
 import { updateActorAvatarFile } from '../../lib/avatar'
31 31
 import { auditLoggerFactory, getAuditIdFromRes, VideoChannelAuditView } from '../../helpers/audit-logger'
32 32
 import { resetSequelizeInstance } from '../../helpers/database-utils'
33
-import { UserModel } from '../../models/account/user'
34 33
 import { JobQueue } from '../../lib/job-queue'
35 34
 import { VideoPlaylistModel } from '../../models/video/video-playlist'
36 35
 import { commonVideoPlaylistFiltersValidator } from '../../middlewares/validators/videos/video-playlists'
@@ -109,16 +108,16 @@ export {
109 108
 
110 109
 // ---------------------------------------------------------------------------
111 110
 
112
-async function listVideoChannels (req: express.Request, res: express.Response, next: express.NextFunction) {
111
+async function listVideoChannels (req: express.Request, res: express.Response) {
113 112
   const serverActor = await getServerActor()
114 113
   const resultList = await VideoChannelModel.listForApi(serverActor.id, req.query.start, req.query.count, req.query.sort)
115 114
 
116 115
   return res.json(getFormattedObjects(resultList.data, resultList.total))
117 116
 }
118 117
 
119
-async function updateVideoChannelAvatar (req: express.Request, res: express.Response, next: express.NextFunction) {
118
+async function updateVideoChannelAvatar (req: express.Request, res: express.Response) {
120 119
   const avatarPhysicalFile = req.files[ 'avatarfile' ][ 0 ]
121
-  const videoChannel = res.locals.videoChannel as VideoChannelModel
120
+  const videoChannel = res.locals.videoChannel
122 121
   const oldVideoChannelAuditKeys = new VideoChannelAuditView(videoChannel.toFormattedJSON())
123 122
 
124 123
   const avatar = await updateActorAvatarFile(avatarPhysicalFile, videoChannel)
@@ -136,7 +135,7 @@ async function addVideoChannel (req: express.Request, res: express.Response) {
136 135
   const videoChannelInfo: VideoChannelCreate = req.body
137 136
 
138 137
   const videoChannelCreated: VideoChannelModel = await sequelizeTypescript.transaction(async t => {
139
-    const account = await AccountModel.load((res.locals.oauth.token.User as UserModel).Account.id, t)
138
+    const account = await AccountModel.load(res.locals.oauth.token.User.Account.id, t)
140 139
 
141 140
     return createVideoChannel(videoChannelInfo, account, t)
142 141
   })
@@ -156,7 +155,7 @@ async function addVideoChannel (req: express.Request, res: express.Response) {
156 155
 }
157 156
 
158 157
 async function updateVideoChannel (req: express.Request, res: express.Response) {
159
-  const videoChannelInstance = res.locals.videoChannel as VideoChannelModel
158
+  const videoChannelInstance = res.locals.videoChannel
160 159
   const videoChannelFieldsSave = videoChannelInstance.toJSON()
161 160
   const oldVideoChannelAuditKeys = new VideoChannelAuditView(videoChannelInstance.toFormattedJSON())
162 161
   const videoChannelInfoToUpdate = req.body as VideoChannelUpdate
@@ -196,7 +195,7 @@ async function updateVideoChannel (req: express.Request, res: express.Response)
196 195
 }
197 196
 
198 197
 async function removeVideoChannel (req: express.Request, res: express.Response) {
199
-  const videoChannelInstance: VideoChannelModel = res.locals.videoChannel
198
+  const videoChannelInstance = res.locals.videoChannel
200 199
 
201 200
   await sequelizeTypescript.transaction(async t => {
202 201
     await VideoPlaylistModel.resetPlaylistsOfChannel(videoChannelInstance.id, t)
@@ -210,7 +209,7 @@ async function removeVideoChannel (req: express.Request, res: express.Response)
210 209
   return res.type('json').status(204).end()
211 210
 }
212 211
 
213
-async function getVideoChannel (req: express.Request, res: express.Response, next: express.NextFunction) {
212
+async function getVideoChannel (req: express.Request, res: express.Response) {
214 213
   const videoChannelWithVideos = await VideoChannelModel.loadAndPopulateAccountAndVideos(res.locals.videoChannel.id)
215 214
 
216 215
   if (videoChannelWithVideos.isOutdated()) {
@@ -236,8 +235,8 @@ async function listVideoChannelPlaylists (req: express.Request, res: express.Res
236 235
   return res.json(getFormattedObjects(resultList.data, resultList.total))
237 236
 }
238 237
 
239
-async function listVideoChannelVideos (req: express.Request, res: express.Response, next: express.NextFunction) {
240
-  const videoChannelInstance: VideoChannelModel = res.locals.videoChannel
238
+async function listVideoChannelVideos (req: express.Request, res: express.Response) {
239
+  const videoChannelInstance = res.locals.videoChannel
241 240
   const followerActorId = isUserAbleToSearchRemoteURI(res) ? null : undefined
242 241
 
243 242
   const resultList = await VideoModel.listForApi({

+ 14
- 16
server/controllers/api/video-playlist.ts View File

@@ -10,7 +10,6 @@ import {
10 10
   setDefaultPagination,
11 11
   setDefaultSort
12 12
 } from '../../middlewares'
13
-import { VideoChannelModel } from '../../models/video/video-channel'
14 13
 import { videoPlaylistsSortValidator } from '../../middlewares/validators'
15 14
 import { buildNSFWFilter, createReqFiles, isUserAbleToSearchRemoteURI } from '../../helpers/express-utils'
16 15
 import { CONFIG, MIMETYPES, sequelizeTypescript, THUMBNAILS_SIZE, VIDEO_PLAYLIST_PRIVACIES } from '../../initializers'
@@ -31,7 +30,6 @@ import { VideoPlaylistCreate } from '../../../shared/models/videos/playlist/vide
31 30
 import { VideoPlaylistPrivacy } from '../../../shared/models/videos/playlist/video-playlist-privacy.model'
32 31
 import { processImage } from '../../helpers/image-utils'
33 32
 import { join } from 'path'
34
-import { UserModel } from '../../models/account/user'
35 33
 import { sendCreateVideoPlaylist, sendDeleteVideoPlaylist, sendUpdateVideoPlaylist } from '../../lib/activitypub/send'
36 34
 import { getVideoPlaylistActivityPubUrl, getVideoPlaylistElementActivityPubUrl } from '../../lib/activitypub/url'
37 35
 import { VideoPlaylistUpdate } from '../../../shared/models/videos/playlist/video-playlist-update.model'
@@ -142,14 +140,14 @@ async function listVideoPlaylists (req: express.Request, res: express.Response)
142 140
 }
143 141
 
144 142
 function getVideoPlaylist (req: express.Request, res: express.Response) {
145
-  const videoPlaylist = res.locals.videoPlaylist as VideoPlaylistModel
143
+  const videoPlaylist = res.locals.videoPlaylist
146 144
 
147 145
   return res.json(videoPlaylist.toFormattedJSON())
148 146
 }
149 147
 
150 148
 async function addVideoPlaylist (req: express.Request, res: express.Response) {
151 149
   const videoPlaylistInfo: VideoPlaylistCreate = req.body
152
-  const user: UserModel = res.locals.oauth.token.User
150
+  const user = res.locals.oauth.token.User
153 151
 
154 152
   const videoPlaylist = new VideoPlaylistModel({
155 153
     name: videoPlaylistInfo.displayName,
@@ -161,7 +159,7 @@ async function addVideoPlaylist (req: express.Request, res: express.Response) {
161 159
   videoPlaylist.url = getVideoPlaylistActivityPubUrl(videoPlaylist) // We use the UUID, so set the URL after building the object
162 160
 
163 161
   if (videoPlaylistInfo.videoChannelId) {
164
-    const videoChannel = res.locals.videoChannel as VideoChannelModel
162
+    const videoChannel = res.locals.videoChannel
165 163
 
166 164
     videoPlaylist.videoChannelId = videoChannel.id
167 165
     videoPlaylist.VideoChannel = videoChannel
@@ -194,7 +192,7 @@ async function addVideoPlaylist (req: express.Request, res: express.Response) {
194 192
 }
195 193
 
196 194
 async function updateVideoPlaylist (req: express.Request, res: express.Response) {
197
-  const videoPlaylistInstance = res.locals.videoPlaylist as VideoPlaylistModel
195
+  const videoPlaylistInstance = res.locals.videoPlaylist
198 196
   const videoPlaylistFieldsSave = videoPlaylistInstance.toJSON()
199 197
   const videoPlaylistInfoToUpdate = req.body as VideoPlaylistUpdate
200 198
   const wasPrivatePlaylist = videoPlaylistInstance.privacy === VideoPlaylistPrivacy.PRIVATE
@@ -219,7 +217,7 @@ async function updateVideoPlaylist (req: express.Request, res: express.Response)
219 217
         if (videoPlaylistInfoToUpdate.videoChannelId === null) {
220 218
           videoPlaylistInstance.videoChannelId = null
221 219
         } else {
222
-          const videoChannel = res.locals.videoChannel as VideoChannelModel
220
+          const videoChannel = res.locals.videoChannel
223 221
 
224 222
           videoPlaylistInstance.videoChannelId = videoChannel.id
225 223
           videoPlaylistInstance.VideoChannel = videoChannel
@@ -262,7 +260,7 @@ async function updateVideoPlaylist (req: express.Request, res: express.Response)
262 260
 }
263 261
 
264 262
 async function removeVideoPlaylist (req: express.Request, res: express.Response) {
265
-  const videoPlaylistInstance: VideoPlaylistModel = res.locals.videoPlaylist
263
+  const videoPlaylistInstance = res.locals.videoPlaylist
266 264
 
267 265
   await sequelizeTypescript.transaction(async t => {
268 266
     await videoPlaylistInstance.destroy({ transaction: t })
@@ -277,8 +275,8 @@ async function removeVideoPlaylist (req: express.Request, res: express.Response)
277 275
 
278 276
 async function addVideoInPlaylist (req: express.Request, res: express.Response) {
279 277
   const body: VideoPlaylistElementCreate = req.body
280
-  const videoPlaylist: VideoPlaylistModel = res.locals.videoPlaylist
281
-  const video: VideoModel = res.locals.video
278
+  const videoPlaylist = res.locals.videoPlaylist
279
+  const video = res.locals.video
282 280
 
283 281
   const playlistElement: VideoPlaylistElementModel = await sequelizeTypescript.transaction(async t => {
284 282
     const position = await VideoPlaylistElementModel.getNextPositionOf(videoPlaylist.id, t)
@@ -323,8 +321,8 @@ async function addVideoInPlaylist (req: express.Request, res: express.Response)
323 321
 
324 322
 async function updateVideoPlaylistElement (req: express.Request, res: express.Response) {
325 323
   const body: VideoPlaylistElementUpdate = req.body
326
-  const videoPlaylist: VideoPlaylistModel = res.locals.videoPlaylist
327
-  const videoPlaylistElement: VideoPlaylistElementModel = res.locals.videoPlaylistElement
324
+  const videoPlaylist = res.locals.videoPlaylist
325
+  const videoPlaylistElement = res.locals.videoPlaylistElement
328 326
 
329 327
   const playlistElement: VideoPlaylistElementModel = await sequelizeTypescript.transaction(async t => {
330 328
     if (body.startTimestamp !== undefined) videoPlaylistElement.startTimestamp = body.startTimestamp
@@ -346,8 +344,8 @@ async function updateVideoPlaylistElement (req: express.Request, res: express.Re
346 344
 }
347 345
 
348 346
 async function removeVideoFromPlaylist (req: express.Request, res: express.Response) {
349
-  const videoPlaylistElement: VideoPlaylistElementModel = res.locals.videoPlaylistElement
350
-  const videoPlaylist: VideoPlaylistModel = res.locals.videoPlaylist
347
+  const videoPlaylistElement = res.locals.videoPlaylistElement
348
+  const videoPlaylist = res.locals.videoPlaylist
351 349
   const positionToDelete = videoPlaylistElement.position
352 350
 
353 351
   await sequelizeTypescript.transaction(async t => {
@@ -368,7 +366,7 @@ async function removeVideoFromPlaylist (req: express.Request, res: express.Respo
368 366
 }
369 367
 
370 368
 async function reorderVideosPlaylist (req: express.Request, res: express.Response) {
371
-  const videoPlaylist: VideoPlaylistModel = res.locals.videoPlaylist
369
+  const videoPlaylist = res.locals.videoPlaylist
372 370
   const body: VideoPlaylistReorder = req.body
373 371
 
374 372
   const start: number = body.startPosition
@@ -416,7 +414,7 @@ async function reorderVideosPlaylist (req: express.Request, res: express.Respons
416 414
 }
417 415
 
418 416
 async function getVideoPlaylistVideos (req: express.Request, res: express.Response) {
419
-  const videoPlaylistInstance: VideoPlaylistModel = res.locals.videoPlaylist
417
+  const videoPlaylistInstance = res.locals.videoPlaylist
420 418
   const followerActorId = isUserAbleToSearchRemoteURI(res) ? null : undefined
421 419
 
422 420
   const resultList = await VideoModel.listForApi({

+ 4
- 6
server/controllers/api/videos/abuse.ts View File

@@ -17,10 +17,8 @@ import {
17 17
   videoAbuseUpdateValidator
18 18
 } from '../../../middlewares'
19 19
 import { AccountModel } from '../../../models/account/account'
20
-import { VideoModel } from '../../../models/video/video'
21 20
 import { VideoAbuseModel } from '../../../models/video/video-abuse'
22 21
 import { auditLoggerFactory, VideoAbuseAuditView } from '../../../helpers/audit-logger'
23
-import { UserModel } from '../../../models/account/user'
24 22
 import { Notifier } from '../../../lib/notifier'
25 23
 import { sendVideoAbuse } from '../../../lib/activitypub/send/send-flag'
26 24
 
@@ -69,7 +67,7 @@ async function listVideoAbuses (req: express.Request, res: express.Response) {
69 67
 }
70 68
 
71 69
 async function updateVideoAbuse (req: express.Request, res: express.Response) {
72
-  const videoAbuse: VideoAbuseModel = res.locals.videoAbuse
70
+  const videoAbuse = res.locals.videoAbuse
73 71
 
74 72
   if (req.body.moderationComment !== undefined) videoAbuse.moderationComment = req.body.moderationComment
75 73
   if (req.body.state !== undefined) videoAbuse.state = req.body.state
@@ -84,7 +82,7 @@ async function updateVideoAbuse (req: express.Request, res: express.Response) {
84 82
 }
85 83
 
86 84
 async function deleteVideoAbuse (req: express.Request, res: express.Response) {
87
-  const videoAbuse: VideoAbuseModel = res.locals.videoAbuse
85
+  const videoAbuse = res.locals.videoAbuse
88 86
 
89 87
   await sequelizeTypescript.transaction(t => {
90 88
     return videoAbuse.destroy({ transaction: t })
@@ -96,11 +94,11 @@ async function deleteVideoAbuse (req: express.Request, res: express.Response) {
96 94
 }
97 95
 
98 96
 async function reportVideoAbuse (req: express.Request, res: express.Response) {
99
-  const videoInstance = res.locals.video as VideoModel
97
+  const videoInstance = res.locals.video
100 98
   const body: VideoAbuseCreate = req.body
101 99
 
102 100
   const videoAbuse: VideoAbuseModel = await sequelizeTypescript.transaction(async t => {
103
-    const reporterAccount = await AccountModel.load((res.locals.oauth.token.User as UserModel).Account.id, t)
101
+    const reporterAccount = await AccountModel.load(res.locals.oauth.token.User.Account.id, t)
104 102
 
105 103
     const abuseToCreate = {
106 104
       reporterAccountId: reporterAccount.id,

+ 3
- 4
server/controllers/api/videos/blacklist.ts View File

@@ -17,7 +17,6 @@ import {
17 17
 import { VideoBlacklistModel } from '../../../models/video/video-blacklist'
18 18
 import { sequelizeTypescript } from '../../../initializers'
19 19
 import { Notifier } from '../../../lib/notifier'
20
-import { VideoModel } from '../../../models/video/video'
21 20
 import { sendDeleteVideo } from '../../../lib/activitypub/send'
22 21
 import { federateVideoIfNeeded } from '../../../lib/activitypub'
23 22
 
@@ -87,7 +86,7 @@ async function addVideoToBlacklist (req: express.Request, res: express.Response)
87 86
 }
88 87
 
89 88
 async function updateVideoBlacklistController (req: express.Request, res: express.Response) {
90
-  const videoBlacklist = res.locals.videoBlacklist as VideoBlacklistModel
89
+  const videoBlacklist = res.locals.videoBlacklist
91 90
 
92 91
   if (req.body.reason !== undefined) videoBlacklist.reason = req.body.reason
93 92
 
@@ -105,8 +104,8 @@ async function listBlacklist (req: express.Request, res: express.Response, next:
105 104
 }
106 105
 
107 106
 async function removeVideoFromBlacklistController (req: express.Request, res: express.Response, next: express.NextFunction) {
108
-  const videoBlacklist = res.locals.videoBlacklist as VideoBlacklistModel
109
-  const video: VideoModel = res.locals.video
107
+  const videoBlacklist = res.locals.videoBlacklist
108
+  const video = res.locals.video
110 109
 
111 110
   await sequelizeTypescript.transaction(async t => {
112 111
     const unfederated = videoBlacklist.unfederated

+ 3
- 4
server/controllers/api/videos/captions.ts View File

@@ -5,7 +5,6 @@ import { createReqFiles } from '../../../helpers/express-utils'
5 5
 import { CONFIG, MIMETYPES, sequelizeTypescript } from '../../../initializers'
6 6
 import { getFormattedObjects } from '../../../helpers/utils'
7 7
 import { VideoCaptionModel } from '../../../models/video/video-caption'
8
-import { VideoModel } from '../../../models/video/video'
9 8
 import { logger } from '../../../helpers/logger'
10 9
 import { federateVideoIfNeeded } from '../../../lib/activitypub'
11 10
 import { moveAndProcessCaptionFile } from '../../../helpers/captions-utils'
@@ -52,7 +51,7 @@ async function listVideoCaptions (req: express.Request, res: express.Response) {
52 51
 
53 52
 async function addVideoCaption (req: express.Request, res: express.Response) {
54 53
   const videoCaptionPhysicalFile = req.files['captionfile'][0]
55
-  const video = res.locals.video as VideoModel
54
+  const video = res.locals.video
56 55
 
57 56
   const videoCaption = new VideoCaptionModel({
58 57
     videoId: video.id,
@@ -74,8 +73,8 @@ async function addVideoCaption (req: express.Request, res: express.Response) {
74 73
 }
75 74
 
76 75
 async function deleteVideoCaption (req: express.Request, res: express.Response) {
77
-  const video = res.locals.video as VideoModel
78
-  const videoCaption = res.locals.videoCaption as VideoCaptionModel
76
+  const video = res.locals.video
77
+  const videoCaption = res.locals.videoCaption
79 78
 
80 79
   await sequelizeTypescript.transaction(async t => {
81 80
     await videoCaption.destroy({ transaction: t })

+ 11
- 12
server/controllers/api/videos/comment.ts View File

@@ -8,7 +8,8 @@ import { buildFormattedCommentTree, createVideoComment } from '../../../lib/vide
8 8
 import {
9 9
   asyncMiddleware,
10 10
   asyncRetryTransactionMiddleware,
11
-  authenticate, optionalAuthenticate,
11
+  authenticate,
12
+  optionalAuthenticate,
12 13
   paginationValidator,
13 14
   setDefaultPagination,
14 15
   setDefaultSort
@@ -21,11 +22,9 @@ import {
21 22
   removeVideoCommentValidator,
22 23
   videoCommentThreadsSortValidator
23 24
 } from '../../../middlewares/validators'
24
-import { VideoModel } from '../../../models/video/video'
25 25
 import { VideoCommentModel } from '../../../models/video/video-comment'
26 26
 import { auditLoggerFactory, CommentAuditView, getAuditIdFromRes } from '../../../helpers/audit-logger'
27 27
 import { AccountModel } from '../../../models/account/account'
28
-import { UserModel } from '../../../models/account/user'
29 28
 import { Notifier } from '../../../lib/notifier'
30 29
 
31 30
 const auditLogger = auditLoggerFactory('comments')
@@ -70,9 +69,9 @@ export {
70 69
 
71 70
 // ---------------------------------------------------------------------------
72 71
 
73
-async function listVideoThreads (req: express.Request, res: express.Response, next: express.NextFunction) {
74
-  const video = res.locals.video as VideoModel
75
-  const user: UserModel = res.locals.oauth ? res.locals.oauth.token.User : undefined
72
+async function listVideoThreads (req: express.Request, res: express.Response) {
73
+  const video = res.locals.video
74
+  const user = res.locals.oauth ? res.locals.oauth.token.User : undefined
76 75
 
77 76
   let resultList: ResultList<VideoCommentModel>
78 77
 
@@ -88,9 +87,9 @@ async function listVideoThreads (req: express.Request, res: express.Response, ne
88 87
   return res.json(getFormattedObjects(resultList.data, resultList.total))
89 88
 }
90 89
 
91
-async function listVideoThreadComments (req: express.Request, res: express.Response, next: express.NextFunction) {
92
-  const video = res.locals.video as VideoModel
93
-  const user: UserModel = res.locals.oauth ? res.locals.oauth.token.User : undefined
90
+async function listVideoThreadComments (req: express.Request, res: express.Response) {
91
+  const video = res.locals.video
92
+  const user = res.locals.oauth ? res.locals.oauth.token.User : undefined
94 93
 
95 94
   let resultList: ResultList<VideoCommentModel>
96 95
 
@@ -110,7 +109,7 @@ async function addVideoCommentThread (req: express.Request, res: express.Respons
110 109
   const videoCommentInfo: VideoCommentCreate = req.body
111 110
 
112 111
   const comment = await sequelizeTypescript.transaction(async t => {
113
-    const account = await AccountModel.load((res.locals.oauth.token.User as UserModel).Account.id, t)
112
+    const account = await AccountModel.load(res.locals.oauth.token.User.Account.id, t)
114 113
 
115 114
     return createVideoComment({
116 115
       text: videoCommentInfo.text,
@@ -132,7 +131,7 @@ async function addVideoCommentReply (req: express.Request, res: express.Response
132 131
   const videoCommentInfo: VideoCommentCreate = req.body
133 132
 
134 133
   const comment = await sequelizeTypescript.transaction(async t => {
135
-    const account = await AccountModel.load((res.locals.oauth.token.User as UserModel).Account.id, t)
134
+    const account = await AccountModel.load(res.locals.oauth.token.User.Account.id, t)
136 135
 
137 136
     return createVideoComment({
138 137
       text: videoCommentInfo.text,
@@ -149,7 +148,7 @@ async function addVideoCommentReply (req: express.Request, res: express.Response
149 148
 }
150 149
 
151 150
 async function removeVideoComment (req: express.Request, res: express.Response) {
152
-  const videoCommentInstance: VideoCommentModel = res.locals.videoComment
151
+  const videoCommentInstance = res.locals.videoComment
153 152
 
154 153
   await sequelizeTypescript.transaction(async t => {
155 154
     await videoCommentInstance.destroy({ transaction: t })

+ 2
- 2
server/controllers/api/videos/import.ts View File

@@ -97,7 +97,7 @@ async function addTorrentImport (req: express.Request, res: express.Response, to
97 97
     state: VideoImportState.PENDING,
98 98
     userId: user.id
99 99
   }
100
-  const videoImport: VideoImportModel = await insertIntoDB(video, res.locals.videoChannel, tags, videoImportAttributes)
100
+  const videoImport = await insertIntoDB(video, res.locals.videoChannel, tags, videoImportAttributes)
101 101
 
102 102
   // Create job to import the video
103 103
   const payload = {
@@ -139,7 +139,7 @@ async function addYoutubeDLImport (req: express.Request, res: express.Response)
139 139
     state: VideoImportState.PENDING,
140 140
     userId: user.id
141 141
   }
142
-  const videoImport: VideoImportModel = await insertIntoDB(video, res.locals.videoChannel, tags, videoImportAttributes)
142
+  const videoImport = await insertIntoDB(video, res.locals.videoChannel, tags, videoImportAttributes)
143 143
 
144 144
   // Create job to import the video
145 145
   const payload = {

+ 3
- 3
server/controllers/api/videos/index.ts View File

@@ -295,7 +295,7 @@ async function addVideo (req: express.Request, res: express.Response) {
295 295
 }
296 296
 
297 297
 async function updateVideo (req: express.Request, res: express.Response) {
298
-  const videoInstance: VideoModel = res.locals.video
298
+  const videoInstance = res.locals.video
299 299
   const videoFieldsSave = videoInstance.toJSON()
300 300
   const oldVideoAuditView = new VideoAuditView(videoInstance.toFormattedDetailsJSON())
301 301
   const videoInfoToUpdate: VideoUpdate = req.body
@@ -407,7 +407,7 @@ async function updateVideo (req: express.Request, res: express.Response) {
407 407
 async function getVideo (req: express.Request, res: express.Response) {
408 408
   // We need more attributes
409 409
   const userId: number = res.locals.oauth ? res.locals.oauth.token.User.id : null
410
-  const video: VideoModel = await VideoModel.loadForGetAPI(res.locals.video.id, undefined, userId)
410
+  const video = await VideoModel.loadForGetAPI(res.locals.video.id, undefined, userId)
411 411
 
412 412
   if (video.isOutdated()) {
413 413
     JobQueue.Instance.createJob({ type: 'activitypub-refresher', payload: { type: 'video', url: video.url } })
@@ -472,7 +472,7 @@ async function listVideos (req: express.Request, res: express.Response) {
472 472
 }
473 473
 
474 474
 async function removeVideo (req: express.Request, res: express.Response) {
475
-  const videoInstance: VideoModel = res.locals.video
475
+  const videoInstance = res.locals.video
476 476
 
477 477
   await sequelizeTypescript.transaction(async t => {
478 478
     await videoInstance.destroy({ transaction: t })

+ 7
- 9
server/controllers/api/videos/ownership.ts View File

@@ -11,8 +11,6 @@ import {
11 11
   videosChangeOwnershipValidator,
12 12
   videosTerminateChangeOwnershipValidator
13 13
 } from '../../../middlewares'
14
-import { AccountModel } from '../../../models/account/account'
15
-import { VideoModel } from '../../../models/video/video'
16 14
 import { VideoChangeOwnershipModel } from '../../../models/video/video-change-ownership'
17 15
 import { VideoChangeOwnershipStatus, VideoPrivacy, VideoState } from '../../../../shared/models/videos'
18 16
 import { VideoChannelModel } from '../../../models/video/video-channel'
@@ -58,9 +56,9 @@ export {
58 56
 // ---------------------------------------------------------------------------
59 57
 
60 58
 async function giveVideoOwnership (req: express.Request, res: express.Response) {
61
-  const videoInstance = res.locals.video as VideoModel
62
-  const initiatorAccountId = (res.locals.oauth.token.User as UserModel).Account.id
63
-  const nextOwner = res.locals.nextOwner as AccountModel
59
+  const videoInstance = res.locals.video
60
+  const initiatorAccountId = res.locals.oauth.token.User.Account.id
61
+  const nextOwner = res.locals.nextOwner
64 62
 
65 63
   await sequelizeTypescript.transaction(t => {
66 64
     return VideoChangeOwnershipModel.findOrCreate({
@@ -85,7 +83,7 @@ async function giveVideoOwnership (req: express.Request, res: express.Response)
85 83
 }
86 84
 
87 85
 async function listVideoOwnership (req: express.Request, res: express.Response) {
88
-  const currentAccountId = (res.locals.oauth.token.User as UserModel).Account.id
86
+  const currentAccountId = res.locals.oauth.token.User.Account.id
89 87
 
90 88
   const resultList = await VideoChangeOwnershipModel.listForApi(
91 89
     currentAccountId,
@@ -99,9 +97,9 @@ async function listVideoOwnership (req: express.Request, res: express.Response)
99 97
 
100 98
 async function acceptOwnership (req: express.Request, res: express.Response) {
101 99
   return sequelizeTypescript.transaction(async t => {
102
-    const videoChangeOwnership = res.locals.videoChangeOwnership as VideoChangeOwnershipModel
100
+    const videoChangeOwnership = res.locals.videoChangeOwnership
103 101
     const targetVideo = videoChangeOwnership.Video
104
-    const channel = res.locals.videoChannel as VideoChannelModel
102
+    const channel = res.locals.videoChannel
105 103
 
106 104
     const oldVideoChannel = await VideoChannelModel.loadByIdAndPopulateAccount(targetVideo.channelId)
107 105
 
@@ -123,7 +121,7 @@ async function acceptOwnership (req: express.Request, res: express.Response) {
123 121
 
124 122
 async function refuseOwnership (req: express.Request, res: express.Response) {
125 123
   return sequelizeTypescript.transaction(async t => {
126
-    const videoChangeOwnership = res.locals.videoChangeOwnership as VideoChangeOwnershipModel
124
+    const videoChangeOwnership = res.locals.videoChangeOwnership
127 125
 
128 126
     videoChangeOwnership.set('status', VideoChangeOwnershipStatus.REFUSED)
129 127
     await videoChangeOwnership.save({ transaction: t })

+ 2
- 3
server/controllers/api/videos/rate.ts View File

@@ -6,7 +6,6 @@ import { getRateUrl, sendVideoRateChange } from '../../../lib/activitypub'
6 6
 import { asyncMiddleware, asyncRetryTransactionMiddleware, authenticate, videoUpdateRateValidator } from '../../../middlewares'
7 7
 import { AccountModel } from '../../../models/account/account'
8 8
 import { AccountVideoRateModel } from '../../../models/account/account-video-rate'
9
-import { VideoModel } from '../../../models/video/video'
10 9
 
11 10
 const rateVideoRouter = express.Router()
12 11
 
@@ -27,8 +26,8 @@ export {
27 26
 async function rateVideo (req: express.Request, res: express.Response) {
28 27
   const body: UserVideoRateUpdate = req.body
29 28
   const rateType = body.rating
30
-  const videoInstance: VideoModel = res.locals.video
31
-  const userAccount: AccountModel = res.locals.oauth.token.User.Account
29
+  const videoInstance = res.locals.video
30
+  const userAccount = res.locals.oauth.token.User.Account
32 31
 
33 32
   await sequelizeTypescript.transaction(async t => {
34 33
     const sequelizeOptions = { transaction: t }

+ 1
- 1
server/controllers/api/videos/watching.ts View File

@@ -21,7 +21,7 @@ export {
21 21
 // ---------------------------------------------------------------------------
22 22
 
23 23
 async function userWatchVideo (req: express.Request, res: express.Response) {
24
-  const user = res.locals.oauth.token.User as UserModel
24
+  const user = res.locals.oauth.token.User
25 25
 
26 26
   const body: UserWatchingVideo = req.body
27 27
   const { id: videoId } = res.locals.video as { id: number }

+ 5
- 7
server/controllers/feeds.ts View File

@@ -11,9 +11,7 @@ import {
11 11
 } from '../middlewares'
12 12
 import { VideoModel } from '../models/video/video'
13 13
 import * as Feed from 'pfeed'
14
-import { AccountModel } from '../models/account/account'
15 14
 import { cacheRoute } from '../middlewares/cache'
16
-import { VideoChannelModel } from '../models/video/video-channel'
17 15
 import { VideoCommentModel } from '../models/video/video-comment'
18 16
 import { buildNSFWFilter } from '../helpers/express-utils'
19 17
 
@@ -42,10 +40,10 @@ export {
42 40
 
43 41
 // ---------------------------------------------------------------------------
44 42
 
45
-async function generateVideoCommentsFeed (req: express.Request, res: express.Response, next: express.NextFunction) {
43
+async function generateVideoCommentsFeed (req: express.Request, res: express.Response) {
46 44
   const start = 0
47 45
 
48
-  const video = res.locals.video as VideoModel
46
+  const video = res.locals.video
49 47
   const videoId: number = video ? video.id : undefined
50 48
 
51 49
   const comments = await VideoCommentModel.listForFeed(start, FEEDS.COUNT, videoId)
@@ -77,11 +75,11 @@ async function generateVideoCommentsFeed (req: express.Request, res: express.Res
77 75
   return sendFeed(feed, req, res)
78 76
 }
79 77
 
80
-async function generateVideoFeed (req: express.Request, res: express.Response, next: express.NextFunction) {
78
+async function generateVideoFeed (req: express.Request, res: express.Response) {
81 79
   const start = 0
82 80
 
83
-  const account: AccountModel = res.locals.account
84
-  const videoChannel: VideoChannelModel = res.locals.videoChannel
81
+  const account = res.locals.account
82
+  const videoChannel = res.locals.videoChannel
85 83
   const nsfw = buildNSFWFilter(res, req.query.nsfw)
86 84
 
87 85
   let name: string

+ 2
- 2
server/controllers/services.ts View File

@@ -23,8 +23,8 @@ export {
23 23
 
24 24
 // ---------------------------------------------------------------------------
25 25
 
26
-function generateOEmbed (req: express.Request, res: express.Response, next: express.NextFunction) {
27
-  const video = res.locals.video as VideoModel
26
+function generateOEmbed (req: express.Request, res: express.Response) {
27
+  const video = res.locals.video
28 28
   const webserverUrl = CONFIG.WEBSERVER.URL
29 29
   const maxHeight = parseInt(req.query.maxheight, 10)
30 30
   const maxWidth = parseInt(req.query.maxwidth, 10)

+ 1
- 1
server/controllers/static.ts View File

@@ -245,7 +245,7 @@ async function downloadVideoFile (req: express.Request, res: express.Response, n
245 245
 
246 246
 function getVideoAndFile (req: express.Request, res: express.Response) {
247 247
   const resolution = parseInt(req.params.resolution, 10)
248
-  const video: VideoModel = res.locals.video
248
+  const video = res.locals.video
249 249
 
250 250
   const videoFile = video.VideoFiles.find(f => f.resolution === resolution)
251 251
 

+ 2
- 3
server/controllers/webfinger.ts View File

@@ -1,7 +1,6 @@
1 1
 import * as express from 'express'
2 2
 import { asyncMiddleware } from '../middlewares'
3 3
 import { webfingerValidator } from '../middlewares/validators'
4
-import { ActorModel } from '../models/activitypub/actor'
5 4
 
6 5
 const webfingerRouter = express.Router()
7 6
 
@@ -18,8 +17,8 @@ export {
18 17
 
19 18
 // ---------------------------------------------------------------------------
20 19
 
21
-function webfingerController (req: express.Request, res: express.Response, next: express.NextFunction) {
22
-  const actor = res.locals.actor as ActorModel
20
+function webfingerController (req: express.Request, res: express.Response) {
21
+  const actor = res.locals.actor
23 22
 
24 23
   const json = {
25 24
     subject: req.query.resource,

+ 2
- 3
server/helpers/express-utils.ts View File

@@ -5,7 +5,6 @@ import { logger } from './logger'
5 5
 import { deleteFileAsync, generateRandomString } from './utils'
6 6
 import { extname } from 'path'
7 7
 import { isArray } from './custom-validators/misc'
8
-import { UserModel } from '../models/account/user'
9 8
 
10 9
 function buildNSFWFilter (res?: express.Response, paramNSFW?: string) {
11 10
   if (paramNSFW === 'true') return true
@@ -13,7 +12,7 @@ function buildNSFWFilter (res?: express.Response, paramNSFW?: string) {
13 12
   if (paramNSFW === 'both') return undefined
14 13
 
15 14
   if (res && res.locals.oauth) {
16
-    const user: UserModel = res.locals.oauth.token.User
15
+    const user = res.locals.oauth.token.User
17 16
 
18 17
     // User does not want NSFW videos
19 18
     if (user.nsfwPolicy === 'do_not_list') return false
@@ -100,7 +99,7 @@ function createReqFiles (
100 99
 }
101 100
 
102 101
 function isUserAbleToSearchRemoteURI (res: express.Response) {
103
-  const user: UserModel = res.locals.oauth ? res.locals.oauth.token.User : undefined
102
+  const user = res.locals.oauth ? res.locals.oauth.token.User : undefined
104 103
 
105 104
   return CONFIG.SEARCH.REMOTE_URI.ANONYMOUS === true ||
106 105
     (CONFIG.SEARCH.REMOTE_URI.USERS === true && user !== undefined)

+ 1
- 2
server/middlewares/activitypub.ts View File

@@ -4,7 +4,6 @@ import { logger } from '../helpers/logger'
4 4
 import { isHTTPSignatureVerified, isJsonLDSignatureVerified, parseHTTPSignature } from '../helpers/peertube-crypto'
5 5
 import { ACCEPT_HEADERS, ACTIVITY_PUB, HTTP_SIGNATURE } from '../initializers'
6 6
 import { getOrCreateActorAndServerAndModel } from '../lib/activitypub'
7
-import { ActorModel } from '../models/activitypub/actor'
8 7
 import { loadActorUrlOrGetFromWebfinger } from '../helpers/webfinger'
9 8
 
10 9
 async function checkSignature (req: Request, res: Response, next: NextFunction) {
@@ -12,7 +11,7 @@ async function checkSignature (req: Request, res: Response, next: NextFunction)
12 11
     const httpSignatureChecked = await checkHttpSignature(req, res)
13 12
     if (httpSignatureChecked !== true) return
14 13
 
15
-    const actor: ActorModel = res.locals.signature.actor
14
+    const actor = res.locals.signature.actor
16 15
 
17 16
     // Forwarded activity
18 17
     const bodyActor = req.body.actor

+ 1
- 2
server/middlewares/user-right.ts View File

@@ -2,11 +2,10 @@ import * as express from 'express'
2 2
 import 'express-validator'
3 3
 import { UserRight } from '../../shared'
4 4
 import { logger } from '../helpers/logger'
5
-import { UserModel } from '../models/account/user'
6 5
 
7 6
 function ensureUserHasRight (userRight: UserRight) {
8 7
   return function (req: express.Request, res: express.Response, next: express.NextFunction) {
9
-    const user = res.locals.oauth.token.user as UserModel
8
+    const user = res.locals.oauth.token.user
10 9
     if (user.hasRight(userRight) === false) {
11 10
       const message = `User ${user.username} does not have right ${UserRight[userRight]} to access to ${req.path}.`
12 11
       logger.info(message)

+ 1
- 2
server/middlewares/validators/activitypub/activity.ts View File

@@ -2,7 +2,6 @@ import * as express from 'express'
2 2
 import { isRootActivityValid } from '../../../helpers/custom-validators/activitypub/activity'
3 3
 import { logger } from '../../../helpers/logger'
4 4
 import { getServerActor } from '../../../helpers/utils'
5
-import { ActorModel } from '../../../models/activitypub/actor'
6 5
 
7 6
 async function activityPubValidator (req: express.Request, res: express.Response, next: express.NextFunction) {
8 7
   logger.debug('Checking activity pub parameters')
@@ -13,7 +12,7 @@ async function activityPubValidator (req: express.Request, res: express.Response
13 12
   }
14 13
 
15 14
   const serverActor = await getServerActor()
16
-  const remoteActor = res.locals.signature.actor as ActorModel
15
+  const remoteActor = res.locals.signature.actor
17 16
   if (serverActor.id === remoteActor.id) {
18 17
     logger.error('Receiving request in INBOX by ourselves!', req.body)
19 18
     return res.status(409).end()

+ 3
- 3
server/middlewares/validators/blocklist.ts View File

@@ -20,7 +20,7 @@ const blockAccountValidator = [
20 20
     if (areValidationErrors(req, res)) return
21 21
     if (!await doesAccountNameWithHostExist(req.body.accountName, res)) return
22 22
 
23
-    const user = res.locals.oauth.token.User as UserModel
23
+    const user = res.locals.oauth.token.User
24 24
     const accountToBlock = res.locals.account
25 25
 
26 26
     if (user.Account.id === accountToBlock.id) {
@@ -44,7 +44,7 @@ const unblockAccountByAccountValidator = [
44 44
     if (areValidationErrors(req, res)) return
45 45
     if (!await doesAccountNameWithHostExist(req.params.accountName, res)) return
46 46
 
47
-    const user = res.locals.oauth.token.User as UserModel
47
+    const user = res.locals.oauth.token.User
48 48
     const targetAccount = res.locals.account
49 49
     if (!await doesUnblockAccountExist(user.Account.id, targetAccount.id, res)) return
50 50
 
@@ -106,7 +106,7 @@ const unblockServerByAccountValidator = [
106 106
 
107 107
     if (areValidationErrors(req, res)) return
108 108
 
109
-    const user = res.locals.oauth.token.User as UserModel
109
+    const user = res.locals.oauth.token.User
110 110
     if (!await doesUnblockServerExist(user.Account.id, req.params.host, res)) return
111 111
 
112 112
     return next()

+ 3
- 7
server/middlewares/validators/redundancy.ts View File

@@ -1,16 +1,12 @@
1 1
 import * as express from 'express'
2 2
 import 'express-validator'
3
-import { param, body } from 'express-validator/check'
3
+import { body, param } from 'express-validator/check'
4 4
 import { exists, isBooleanValid, isIdOrUUIDValid, toIntOrNull } from '../../helpers/custom-validators/misc'
5 5
 import { doesVideoExist } from '../../helpers/custom-validators/videos'
6 6
 import { logger } from '../../helpers/logger'
7 7
 import { areValidationErrors } from './utils'
8
-import { VideoModel } from '../../models/video/video'
9 8
 import { VideoRedundancyModel } from '../../models/redundancy/video-redundancy'
10 9
 import { isHostValid } from '../../helpers/custom-validators/servers'
11
-import { getServerActor } from '../../helpers/utils'
12
-import { ActorFollowModel } from '../../models/activitypub/actor-follow'
13
-import { SERVER_ACTOR_NAME } from '../../initializers'
14 10
 import { ServerModel } from '../../models/server/server'
15 11
 
16 12
 const videoFileRedundancyGetValidator = [
@@ -29,7 +25,7 @@ const videoFileRedundancyGetValidator = [
29 25
     if (areValidationErrors(req, res)) return
30 26
     if (!await doesVideoExist(req.params.videoId, res)) return
31 27
 
32
-    const video: VideoModel = res.locals.video
28
+    const video = res.locals.video
33 29
     const videoFile = video.VideoFiles.find(f => {
34 30
       return f.resolution === req.params.resolution && (!req.params.fps || f.fps === req.params.fps)
35 31
     })
@@ -55,7 +51,7 @@ const videoPlaylistRedundancyGetValidator = [
55 51
     if (areValidationErrors(req, res)) return
56 52
     if (!await doesVideoExist(req.params.videoId, res)) return
57 53
 
58
-    const video: VideoModel = res.locals.video
54
+    const video = res.locals.video
59 55
     const videoStreamingPlaylist = video.VideoStreamingPlaylists.find(p => p === req.params.streamingPlaylistType)
60 56
 
61 57
     if (!videoStreamingPlaylist) return res.status(404).json({ error: 'Video playlist not found.' })

+ 1
- 2
server/middlewares/validators/user-subscriptions.ts View File

@@ -5,7 +5,6 @@ import { logger } from '../../helpers/logger'
5 5
 import { areValidationErrors } from './utils'
6 6
 import { ActorFollowModel } from '../../models/activitypub/actor-follow'
7 7
 import { areValidActorHandles, isValidActorHandle } from '../../helpers/custom-validators/activitypub/actor'
8
-import { UserModel } from '../../models/account/user'
9 8
 import { CONFIG } from '../../initializers'
10 9
 import { toArray } from '../../helpers/custom-validators/misc'
11 10
 
@@ -46,7 +45,7 @@ const userSubscriptionGetValidator = [
46 45
     let [ name, host ] = req.params.uri.split('@')
47 46
     if (host === CONFIG.WEBSERVER.HOST) host = null
48 47
 
49
-    const user: UserModel = res.locals.oauth.token.User
48
+    const user = res.locals.oauth.token.User
50 49
     const subscription = await ActorFollowModel.loadByActorAndTargetNameAndHostForAPI(user.Account.Actor.id, name, host)
51 50
 
52 51
     if (!subscription || !subscription.ActorFollowing.VideoChannel) {

+ 6
- 6
server/middlewares/validators/users.ts View File

@@ -14,7 +14,8 @@ import {
14 14
   isUserRoleValid,
15 15
   isUserUsernameValid,
16 16
   isUserVideoQuotaDailyValid,
17
-  isUserVideoQuotaValid, isUserVideosHistoryEnabledValid
17
+  isUserVideoQuotaValid,
18
+  isUserVideosHistoryEnabledValid
18 19
 } from '../../helpers/custom-validators/users'
19 20
 import { doesVideoExist } from '../../helpers/custom-validators/videos'
20 21
 import { logger } from '../../helpers/logger'
@@ -100,7 +101,7 @@ const usersBlockingValidator = [
100 101
 
101 102
 const deleteMeValidator = [
102 103
   async (req: express.Request, res: express.Response, next: express.NextFunction) => {
103
-    const user: UserModel = res.locals.oauth.token.User
104
+    const user = res.locals.oauth.token.User
104 105
     if (user.username === 'root') {
105 106
       return res.status(400)
106 107
                 .send({ error: 'You cannot delete your root account.' })
@@ -159,8 +160,7 @@ const usersUpdateMeValidator = [
159 160
                   .end()
160 161
       }
161 162
 
162
-      const user: UserModel = res.locals.oauth.token.User
163
-
163
+      const user= res.locals.oauth.token.User
164 164
       if (await user.isPasswordMatch(req.body.currentPassword) !== true) {
165 165
         return res.status(401)
166 166
                   .send({ error: 'currentPassword is invalid.' })
@@ -257,7 +257,7 @@ const usersResetPasswordValidator = [
257 257
     if (areValidationErrors(req, res)) return
258 258
     if (!await checkUserIdExist(req.params.id, res)) return
259 259
 
260
-    const user = res.locals.user as UserModel
260
+    const user = res.locals.user
261 261
     const redisVerificationString = await Redis.Instance.getResetPasswordLink(user.id)
262 262
 
263 263
     if (redisVerificationString !== req.body.verificationString) {
@@ -299,7 +299,7 @@ const usersVerifyEmailValidator = [
299 299
     if (areValidationErrors(req, res)) return
300 300
     if (!await checkUserIdExist(req.params.id, res)) return
301 301
 
302
-    const user = res.locals.user as UserModel
302
+    const user = res.locals.user
303 303
     const redisVerificationString = await Redis.Instance.getVerifyEmailLink(user.id)
304 304
 
305 305
     if (redisVerificationString !== req.body.verificationString) {

+ 1
- 2
server/middlewares/validators/videos/video-blacklist.ts View File

@@ -5,7 +5,6 @@ import { doesVideoExist } from '../../../helpers/custom-validators/videos'
5 5
 import { logger } from '../../../helpers/logger'
6 6
 import { areValidationErrors } from '../utils'
7 7
 import { doesVideoBlacklistExist, isVideoBlacklistReasonValid } from '../../../helpers/custom-validators/video-blacklist'
8
-import { VideoModel } from '../../../models/video/video'
9 8
 
10 9
 const videosBlacklistRemoveValidator = [
11 10
   param('videoId').custom(isIdOrUUIDValid).not().isEmpty().withMessage('Should have a valid videoId'),
@@ -37,7 +36,7 @@ const videosBlacklistAddValidator = [
37 36
     if (areValidationErrors(req, res)) return
38 37
     if (!await doesVideoExist(req.params.videoId, res)) return
39 38
 
40
-    const video: VideoModel = res.locals.video
39
+    const video = res.locals.video
41 40
     if (req.body.unfederate === true && video.remote === true) {
42 41
       return res
43 42
         .status(409)

+ 8
- 9
server/middlewares/validators/videos/video-playlists.ts View File

@@ -103,7 +103,7 @@ const videoPlaylistsDeleteValidator = [
103 103
 
104 104
     if (!await doesVideoPlaylistExist(req.params.playlistId, res)) return
105 105
 
106
-    const videoPlaylist: VideoPlaylistModel = res.locals.videoPlaylist
106
+    const videoPlaylist = res.locals.videoPlaylist
107 107
     if (videoPlaylist.type === VideoPlaylistType.WATCH_LATER) {
108 108
       return res.status(400)
109 109
                 .json({ error: 'Cannot delete a watch later playlist.' })
@@ -128,7 +128,7 @@ const videoPlaylistsGetValidator = [
128 128
 
129 129
     if (!await doesVideoPlaylistExist(req.params.playlistId, res)) return
130 130
 
131
-    const videoPlaylist: VideoPlaylistModel = res.locals.videoPlaylist
131
+    const videoPlaylist = res.locals.videoPlaylist
132 132
 
133 133
     // Video is unlisted, check we used the uuid to fetch it
134 134
     if (videoPlaylist.privacy === VideoPlaylistPrivacy.UNLISTED) {
@@ -140,8 +140,7 @@ const videoPlaylistsGetValidator = [
140 140
     if (videoPlaylist.privacy === VideoPlaylistPrivacy.PRIVATE) {
141 141
       await authenticatePromiseIfNeeded(req, res)
142 142
 
143
-      const user: UserModel = res.locals.oauth ? res.locals.oauth.token.User : null
144
-
143
+      const user = res.locals.oauth ? res.locals.oauth.token.User : null
145 144
       if (
146 145
         !user ||
147 146
         (videoPlaylist.OwnerAccount.userId !== user.id && !user.hasRight(UserRight.UPDATE_ANY_VIDEO_PLAYLIST))
@@ -177,8 +176,8 @@ const videoPlaylistsAddVideoValidator = [
177 176
     if (!await doesVideoPlaylistExist(req.params.playlistId, res, 'all')) return
178 177
     if (!await doesVideoExist(req.body.videoId, res, 'only-video')) return
179 178
 
180
-    const videoPlaylist: VideoPlaylistModel = res.locals.videoPlaylist
181
-    const video: VideoModel = res.locals.video
179
+    const videoPlaylist = res.locals.videoPlaylist
180
+    const video = res.locals.video
182 181
 
183 182
     const videoPlaylistElement = await VideoPlaylistElementModel.loadByPlaylistAndVideo(videoPlaylist.id, video.id)
184 183
     if (videoPlaylistElement) {
@@ -217,8 +216,8 @@ const videoPlaylistsUpdateOrRemoveVideoValidator = [
217 216
     if (!await doesVideoPlaylistExist(req.params.playlistId, res, 'all')) return
218 217
     if (!await doesVideoExist(req.params.videoId, res, 'id')) return
219 218
 
220
-    const videoPlaylist: VideoPlaylistModel = res.locals.videoPlaylist
221
-    const video: VideoModel = res.locals.video
219
+    const videoPlaylist = res.locals.videoPlaylist
220
+    const video = res.locals.video
222 221
 
223 222
     const videoPlaylistElement = await VideoPlaylistElementModel.loadByPlaylistAndVideo(videoPlaylist.id, video.id)
224 223
     if (!videoPlaylistElement) {
@@ -284,7 +283,7 @@ const videoPlaylistsReorderVideosValidator = [
284 283
 
285 284
     if (!await doesVideoPlaylistExist(req.params.playlistId, res, 'all')) return
286 285
 
287
-    const videoPlaylist: VideoPlaylistModel = res.locals.videoPlaylist
286
+    const videoPlaylist = res.locals.videoPlaylist
288 287
     if (!checkUserCanManageVideoPlaylist(res.locals.oauth.token.User, videoPlaylist, UserRight.UPDATE_ANY_VIDEO_PLAYLIST, res)) return
289 288
 
290 289
     const nextPosition = await VideoPlaylistElementModel.getNextPositionOf(videoPlaylist.id)

+ 1
- 2
server/middlewares/validators/videos/video-shares.ts View File

@@ -6,7 +6,6 @@ import { doesVideoExist } from '../../../helpers/custom-validators/videos'
6 6
 import { logger } from '../../../helpers/logger'
7 7
 import { VideoShareModel } from '../../../models/video/video-share'
8 8
 import { areValidationErrors } from '../utils'
9
-import { VideoModel } from '../../../models/video/video'
10 9
 
11 10
 const videosShareValidator = [
12 11
   param('id').custom(isIdOrUUIDValid).not().isEmpty().withMessage('Should have a valid id'),
@@ -18,7 +17,7 @@ const videosShareValidator = [
18 17
     if (areValidationErrors(req, res)) return
19 18
     if (!await doesVideoExist(req.params.id, res)) return
20 19
 
21
-    const video: VideoModel = res.locals.video
20
+    const video = res.locals.video
22 21
 
23 22
     const share = await VideoShareModel.load(req.params.actorId, video.id)
24 23
     if (!share) {

+ 1
- 2
server/middlewares/validators/videos/video-watch.ts View File

@@ -4,7 +4,6 @@ import { isIdOrUUIDValid } from '../../../helpers/custom-validators/misc'
4 4
 import { doesVideoExist } from '../../../helpers/custom-validators/videos'
5 5
 import { areValidationErrors } from '../utils'
6 6
 import { logger } from '../../../helpers/logger'
7
-import { UserModel } from '../../../models/account/user'
8 7
 
9 8
 const videoWatchingValidator = [
10 9
   param('videoId').custom(isIdOrUUIDValid).not().isEmpty().withMessage('Should have a valid id'),
@@ -18,7 +17,7 @@ const videoWatchingValidator = [
18 17
     if (areValidationErrors(req, res)) return
19 18
     if (!await doesVideoExist(req.params.videoId, res, 'id')) return
20 19
 
21
-    const user = res.locals.oauth.token.User as UserModel
20
+    const user = res.locals.oauth.token.User
22 21
     if (user.videosHistoryEnabled === false) {
23 22
       logger.warn('Cannot set videos to watch by user %d: videos history is disabled.', user.id)
24 23
       return res.status(409).end()

+ 6
- 6
server/middlewares/validators/videos/videos.ts View File

@@ -130,7 +130,7 @@ const videosUpdateValidator = getCommonVideoEditAttributes().concat([
130 130
 ])
131 131
 
132 132
 async function checkVideoFollowConstraints (req: express.Request, res: express.Response, next: express.NextFunction) {
133
-  const video: VideoModel = res.locals.video
133
+  const video = res.locals.video
134 134
 
135 135
   // Anybody can watch local videos
136 136
   if (video.isOwned() === true) return next()
@@ -164,13 +164,13 @@ const videosCustomGetValidator = (fetchType: VideoFetchType) => {
164 164
       if (areValidationErrors(req, res)) return
165 165
       if (!await doesVideoExist(req.params.id, res, fetchType)) return
166 166
 
167
-      const video: VideoModel = res.locals.video
167
+      const video = res.locals.video
168 168
 
169 169
       // Video private or blacklisted
170 170
       if (video.privacy === VideoPrivacy.PRIVATE || video.VideoBlacklist) {
171 171
         await authenticatePromiseIfNeeded(req, res)
172 172
 
173
-        const user: UserModel = res.locals.oauth ? res.locals.oauth.token.User : null
173
+        const user = res.locals.oauth ? res.locals.oauth.token.User : null
174 174
 
175 175
         // Only the owner or a user that have blacklist rights can see the video
176 176
         if (
@@ -256,7 +256,7 @@ const videosTerminateChangeOwnershipValidator = [
256 256
     return next()
257 257
   },
258 258
   async (req: express.Request, res: express.Response, next: express.NextFunction) => {
259
-    const videoChangeOwnership = res.locals.videoChangeOwnership as VideoChangeOwnershipModel
259
+    const videoChangeOwnership = res.locals.videoChangeOwnership
260 260
 
261 261
     if (videoChangeOwnership.status === VideoChangeOwnershipStatus.WAITING) {
262 262
       return next()
@@ -275,7 +275,7 @@ const videosAcceptChangeOwnershipValidator = [
275 275
     if (!await doesVideoChannelOfAccountExist(body.channelId, res.locals.oauth.token.User, res)) return
276 276
 
277 277
     const user = res.locals.oauth.token.User
278
-    const videoChangeOwnership = res.locals.videoChangeOwnership as VideoChangeOwnershipModel
278
+    const videoChangeOwnership = res.locals.videoChangeOwnership
279 279
     const isAble = await user.isAbleToUploadVideo(videoChangeOwnership.Video.getOriginalFile())
280 280
     if (isAble === false) {
281 281
       res.status(403)
@@ -395,7 +395,7 @@ const commonVideosFiltersValidator = [
395 395
 
396 396
     if (areValidationErrors(req, res)) return
397 397
 
398
-    const user: UserModel = res.locals.oauth ? res.locals.oauth.token.User : undefined
398
+    const user = res.locals.oauth ? res.locals.oauth.token.User : undefined
399 399
     if (req.query.filter === 'all-local' && (!user || user.hasRight(UserRight.SEE_ALL_VIDEOS) === false)) {
400 400
       res.status(401)
401 401
          .json({ error: 'You are not allowed to see all local videos.' })

+ 82
- 0
server/typings/express.ts View File

@@ -0,0 +1,82 @@
1
+import { VideoChannelModel } from '../models/video/video-channel'
2
+import { VideoPlaylistModel } from '../models/video/video-playlist'
3
+import { VideoPlaylistElementModel } from '../models/video/video-playlist-element'
4
+import { UserModel } from '../models/account/user'
5
+import { VideoModel } from '../models/video/video'
6
+import { AccountModel } from '../models/account/account'
7
+import { VideoChangeOwnershipModel } from '../models/video/video-change-ownership'
8
+import { ActorModel } from '../models/activitypub/actor'
9
+import { VideoCommentModel } from '../models/video/video-comment'
10
+import { VideoShareModel } from '../models/video/video-share'
11
+import { AccountVideoRateModel } from '../models/account/account-video-rate'
12
+import { ActorFollowModel } from '../models/activitypub/actor-follow'
13
+import { ServerModel } from '../models/server/server'
14
+import { VideoFileModel } from '../models/video/video-file'
15
+import { VideoRedundancyModel } from '../models/redundancy/video-redundancy'
16
+import { ServerBlocklistModel } from '../models/server/server-blocklist'
17
+import { AccountBlocklistModel } from '../models/account/account-blocklist'
18
+import { VideoImportModel } from '../models/video/video-import'
19
+import { VideoAbuseModel } from '../models/video/video-abuse'
20
+import { VideoBlacklistModel } from '../models/video/video-blacklist'
21
+import { VideoCaptionModel } from '../models/video/video-caption'
22
+import { VideoStreamingPlaylistModel } from '../models/video/video-streaming-playlist'
23
+
24
+declare module 'express' {
25
+
26
+  interface Response {
27
+    locals: {
28
+      video?: VideoModel
29
+      videoShare?: VideoShareModel
30
+      videoFile?: VideoFileModel
31
+
32
+      videoImport?: VideoImportModel
33
+
34
+      videoBlacklist?: VideoBlacklistModel
35
+
36
+      videoCaption?: VideoCaptionModel
37
+
38
+      videoAbuse?: VideoAbuseModel
39
+
40
+      videoStreamingPlaylist?: VideoStreamingPlaylistModel
41
+
42
+      videoChannel?: VideoChannelModel
43
+
44
+      videoPlaylist?: VideoPlaylistModel
45
+      videoPlaylistElement?: VideoPlaylistElementModel
46
+
47
+      accountVideoRate?: AccountVideoRateModel
48
+
49
+      videoComment?: VideoCommentModel
50
+      videoCommentThread?: VideoCommentModel
51
+
52
+      follow?: ActorFollowModel
53
+      subscription?: ActorFollowModel
54
+
55
+      nextOwner?: AccountModel
56
+      videoChangeOwnership?: VideoChangeOwnershipModel
57
+      account?: AccountModel
58
+      actor?: ActorModel
59
+      user?: UserModel
60
+
61
+      server?: ServerModel
62
+
63
+      videoRedundancy?: VideoRedundancyModel
64
+
65
+      accountBlock?: AccountBlocklistModel
66
+      serverBlock?: ServerBlocklistModel
67
+
68
+      oauth?: {
69
+        token: {
70
+          User: UserModel
71
+          user: UserModel
72
+        }
73
+      }
74
+
75
+      signature?: {
76
+        actor: ActorModel
77
+      }
78
+
79
+      authenticated?: boolean
80
+    }
81
+  }
82
+}

+ 1
- 5
tsconfig.json View File

@@ -14,11 +14,7 @@
14 14
       "es2016",
15 15
       "es2017"
16 16
     ],
17
-    "types": [
18
-      "node",
19
-      "chai-xml",
20
-      "chai-json-schema"
21
-    ]
17
+    "typeRoots": [ "node_modules/@types", "server/typings" ]
22 18
   },
23 19
   "exclude": [
24 20
     "client/node_modules",

Loading…
Cancel
Save