aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/controllers
diff options
context:
space:
mode:
Diffstat (limited to 'server/controllers')
-rw-r--r--server/controllers/activitypub/client.ts36
-rw-r--r--server/controllers/activitypub/inbox.ts9
-rw-r--r--server/controllers/activitypub/outbox.ts2
-rw-r--r--server/controllers/api/accounts.ts7
-rw-r--r--server/controllers/api/index.ts2
-rw-r--r--server/controllers/api/server/follows.ts10
-rw-r--r--server/controllers/api/server/redundancy.ts5
-rw-r--r--server/controllers/api/server/server-blocklist.ts10
-rw-r--r--server/controllers/api/users/index.ts30
-rw-r--r--server/controllers/api/users/me.ts20
-rw-r--r--server/controllers/api/users/my-blocklist.ts17
-rw-r--r--server/controllers/api/users/my-history.ts4
-rw-r--r--server/controllers/api/users/my-notifications.ts11
-rw-r--r--server/controllers/api/users/my-subscriptions.ts15
-rw-r--r--server/controllers/api/users/my-video-playlists.ts3
-rw-r--r--server/controllers/api/video-channel.ts19
-rw-r--r--server/controllers/api/video-playlist.ts30
-rw-r--r--server/controllers/api/videos/abuse.ts10
-rw-r--r--server/controllers/api/videos/blacklist.ts7
-rw-r--r--server/controllers/api/videos/captions.ts7
-rw-r--r--server/controllers/api/videos/comment.ts23
-rw-r--r--server/controllers/api/videos/import.ts4
-rw-r--r--server/controllers/api/videos/index.ts6
-rw-r--r--server/controllers/api/videos/ownership.ts16
-rw-r--r--server/controllers/api/videos/rate.ts5
-rw-r--r--server/controllers/api/videos/watching.ts2
-rw-r--r--server/controllers/feeds.ts12
-rw-r--r--server/controllers/services.ts4
-rw-r--r--server/controllers/static.ts2
-rw-r--r--server/controllers/webfinger.ts5
30 files changed, 152 insertions, 181 deletions
diff --git a/server/controllers/activitypub/client.ts b/server/controllers/activitypub/client.ts
index cc2671fc1..e06aa35f4 100644
--- a/server/controllers/activitypub/client.ts
+++ b/server/controllers/activitypub/client.ts
@@ -169,27 +169,27 @@ export {
169// --------------------------------------------------------------------------- 169// ---------------------------------------------------------------------------
170 170
171function accountController (req: express.Request, res: express.Response) { 171function accountController (req: express.Request, res: express.Response) {
172 const account: AccountModel = res.locals.account 172 const account = res.locals.account
173 173
174 return activityPubResponse(activityPubContextify(account.toActivityPubObject()), res) 174 return activityPubResponse(activityPubContextify(account.toActivityPubObject()), res)
175} 175}
176 176
177async function accountFollowersController (req: express.Request, res: express.Response) { 177async function accountFollowersController (req: express.Request, res: express.Response) {
178 const account: AccountModel = res.locals.account 178 const account = res.locals.account
179 const activityPubResult = await actorFollowers(req, account.Actor) 179 const activityPubResult = await actorFollowers(req, account.Actor)
180 180
181 return activityPubResponse(activityPubContextify(activityPubResult), res) 181 return activityPubResponse(activityPubContextify(activityPubResult), res)
182} 182}
183 183
184async function accountFollowingController (req: express.Request, res: express.Response) { 184async function accountFollowingController (req: express.Request, res: express.Response) {
185 const account: AccountModel = res.locals.account 185 const account = res.locals.account
186 const activityPubResult = await actorFollowing(req, account.Actor) 186 const activityPubResult = await actorFollowing(req, account.Actor)
187 187
188 return activityPubResponse(activityPubContextify(activityPubResult), res) 188 return activityPubResponse(activityPubContextify(activityPubResult), res)
189} 189}
190 190
191async function accountPlaylistsController (req: express.Request, res: express.Response) { 191async function accountPlaylistsController (req: express.Request, res: express.Response) {
192 const account: AccountModel = res.locals.account 192 const account = res.locals.account
193 const activityPubResult = await actorPlaylists(req, account) 193 const activityPubResult = await actorPlaylists(req, account)
194 194
195 return activityPubResponse(activityPubContextify(activityPubResult), res) 195 return activityPubResponse(activityPubContextify(activityPubResult), res)
@@ -197,7 +197,7 @@ async function accountPlaylistsController (req: express.Request, res: express.Re
197 197
198function getAccountVideoRate (rateType: VideoRateType) { 198function getAccountVideoRate (rateType: VideoRateType) {
199 return (req: express.Request, res: express.Response) => { 199 return (req: express.Request, res: express.Response) => {
200 const accountVideoRate: AccountVideoRateModel = res.locals.accountVideoRate 200 const accountVideoRate = res.locals.accountVideoRate
201 201
202 const byActor = accountVideoRate.Account.Actor 202 const byActor = accountVideoRate.Account.Actor
203 const url = getRateUrl(rateType, byActor, accountVideoRate.Video) 203 const url = getRateUrl(rateType, byActor, accountVideoRate.Video)
@@ -211,7 +211,7 @@ function getAccountVideoRate (rateType: VideoRateType) {
211 211
212async function videoController (req: express.Request, res: express.Response) { 212async function videoController (req: express.Request, res: express.Response) {
213 // We need more attributes 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 if (video.url.startsWith(CONFIG.WEBSERVER.URL) === false) return res.redirect(video.url) 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
232async function videoAnnounceController (req: express.Request, res: express.Response) { 232async 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 if (share.url.startsWith(CONFIG.WEBSERVER.URL) === false) return res.redirect(share.url) 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
242async function videoAnnouncesController (req: express.Request, res: express.Response) { 242async function videoAnnouncesController (req: express.Request, res: express.Response) {
243 const video: VideoModel = res.locals.video 243 const video = res.locals.video
244 244
245 const handler = async (start: number, count: number) => { 245 const handler = async (start: number, count: number) => {
246 const result = await VideoShareModel.listAndCountByVideoId(video.id, start, count) 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
257async function videoLikesController (req: express.Request, res: express.Response) { 257async function videoLikesController (req: express.Request, res: express.Response) {
258 const video: VideoModel = res.locals.video 258 const video = res.locals.video
259 const json = await videoRates(req, 'like', video, getVideoLikesActivityPubUrl(video)) 259 const json = await videoRates(req, 'like', video, getVideoLikesActivityPubUrl(video))
260 260
261 return activityPubResponse(activityPubContextify(json), res) 261 return activityPubResponse(activityPubContextify(json), res)
262} 262}
263 263
264async function videoDislikesController (req: express.Request, res: express.Response) { 264async function videoDislikesController (req: express.Request, res: express.Response) {
265 const video: VideoModel = res.locals.video 265 const video = res.locals.video
266 const json = await videoRates(req, 'dislike', video, getVideoDislikesActivityPubUrl(video)) 266 const json = await videoRates(req, 'dislike', video, getVideoDislikesActivityPubUrl(video))
267 267
268 return activityPubResponse(activityPubContextify(json), res) 268 return activityPubResponse(activityPubContextify(json), res)
269} 269}
270 270
271async function videoCommentsController (req: express.Request, res: express.Response) { 271async function videoCommentsController (req: express.Request, res: express.Response) {
272 const video: VideoModel = res.locals.video 272 const video = res.locals.video
273 273
274 const handler = async (start: number, count: number) => { 274 const handler = async (start: number, count: number) => {
275 const result = await VideoCommentModel.listAndCountByVideoId(video.id, start, count) 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
286async function videoChannelController (req: express.Request, res: express.Response) { 286async function videoChannelController (req: express.Request, res: express.Response) {
287 const videoChannel: VideoChannelModel = res.locals.videoChannel 287 const videoChannel = res.locals.videoChannel
288 288
289 return activityPubResponse(activityPubContextify(videoChannel.toActivityPubObject()), res) 289 return activityPubResponse(activityPubContextify(videoChannel.toActivityPubObject()), res)
290} 290}
291 291
292async function videoChannelFollowersController (req: express.Request, res: express.Response) { 292async function videoChannelFollowersController (req: express.Request, res: express.Response) {
293 const videoChannel: VideoChannelModel = res.locals.videoChannel 293 const videoChannel = res.locals.videoChannel
294 const activityPubResult = await actorFollowers(req, videoChannel.Actor) 294 const activityPubResult = await actorFollowers(req, videoChannel.Actor)
295 295
296 return activityPubResponse(activityPubContextify(activityPubResult), res) 296 return activityPubResponse(activityPubContextify(activityPubResult), res)
297} 297}
298 298
299async function videoChannelFollowingController (req: express.Request, res: express.Response) { 299async function videoChannelFollowingController (req: express.Request, res: express.Response) {
300 const videoChannel: VideoChannelModel = res.locals.videoChannel 300 const videoChannel = res.locals.videoChannel
301 const activityPubResult = await actorFollowing(req, videoChannel.Actor) 301 const activityPubResult = await actorFollowing(req, videoChannel.Actor)
302 302
303 return activityPubResponse(activityPubContextify(activityPubResult), res) 303 return activityPubResponse(activityPubContextify(activityPubResult), res)
304} 304}
305 305
306async function videoCommentController (req: express.Request, res: express.Response) { 306async function videoCommentController (req: express.Request, res: express.Response) {
307 const videoComment: VideoCommentModel = res.locals.videoComment 307 const videoComment = res.locals.videoComment
308 308
309 if (videoComment.url.startsWith(CONFIG.WEBSERVER.URL) === false) return res.redirect(videoComment.url) 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
325async function videoRedundancyController (req: express.Request, res: express.Response) { 325async function videoRedundancyController (req: express.Request, res: express.Response) {
326 const videoRedundancy: VideoRedundancyModel = res.locals.videoRedundancy 326 const videoRedundancy = res.locals.videoRedundancy
327 if (videoRedundancy.url.startsWith(CONFIG.WEBSERVER.URL) === false) return res.redirect(videoRedundancy.url) 327 if (videoRedundancy.url.startsWith(CONFIG.WEBSERVER.URL) === false) return res.redirect(videoRedundancy.url)
328 328
329 const serverActor = await getServerActor() 329 const serverActor = await getServerActor()
@@ -340,7 +340,7 @@ async function videoRedundancyController (req: express.Request, res: express.Res
340} 340}
341 341
342async function videoPlaylistController (req: express.Request, res: express.Response) { 342async function videoPlaylistController (req: express.Request, res: express.Response) {
343 const playlist: VideoPlaylistModel = res.locals.videoPlaylist 343 const playlist = res.locals.videoPlaylist
344 344
345 // We need more attributes 345 // We need more attributes
346 playlist.OwnerAccount = await AccountModel.load(playlist.ownerAccountId) 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
355async function videoPlaylistElementController (req: express.Request, res: express.Response) { 355async function videoPlaylistElementController (req: express.Request, res: express.Response) {
356 const videoPlaylistElement: VideoPlaylistElementModel = res.locals.videoPlaylistElement 356 const videoPlaylistElement = res.locals.videoPlaylistElement
357 357
358 const json = videoPlaylistElement.toActivityPubObject() 358 const json = videoPlaylistElement.toActivityPubObject()
359 return activityPubResponse(activityPubContextify(json), res) 359 return activityPubResponse(activityPubContextify(json), res)
diff --git a/server/controllers/activitypub/inbox.ts b/server/controllers/activitypub/inbox.ts
index f0e65015b..38d5c51df 100644
--- a/server/controllers/activitypub/inbox.ts
+++ b/server/controllers/activitypub/inbox.ts
@@ -5,8 +5,6 @@ import { logger } from '../../helpers/logger'
5import { processActivities } from '../../lib/activitypub/process/process' 5import { processActivities } from '../../lib/activitypub/process/process'
6import { asyncMiddleware, checkSignature, localAccountValidator, localVideoChannelValidator, signatureValidator } from '../../middlewares' 6import { asyncMiddleware, checkSignature, localAccountValidator, localVideoChannelValidator, signatureValidator } from '../../middlewares'
7import { activityPubValidator } from '../../middlewares/validators/activitypub/activity' 7import { activityPubValidator } from '../../middlewares/validators/activitypub/activity'
8import { VideoChannelModel } from '../../models/video/video-channel'
9import { AccountModel } from '../../models/account/account'
10import { queue } from 'async' 8import { queue } from 'async'
11import { ActorModel } from '../../models/activitypub/actor' 9import { ActorModel } from '../../models/activitypub/actor'
12 10
@@ -66,12 +64,7 @@ function inboxController (req: express.Request, res: express.Response) {
66 activities = activities.filter(a => isActivityValid(a)) 64 activities = activities.filter(a => isActivityValid(a))
67 logger.debug('We keep %d activities.', activities.length, { activities }) 65 logger.debug('We keep %d activities.', activities.length, { activities })
68 66
69 let accountOrChannel: VideoChannelModel | AccountModel 67 const accountOrChannel = res.locals.account || res.locals.videoChannel
70 if (res.locals.account) {
71 accountOrChannel = res.locals.account
72 } else if (res.locals.videoChannel) {
73 accountOrChannel = res.locals.videoChannel
74 }
75 68
76 logger.info('Receiving inbox requests for %d activities by %s.', activities.length, res.locals.signature.actor.url) 69 logger.info('Receiving inbox requests for %d activities by %s.', activities.length, res.locals.signature.actor.url)
77 70
diff --git a/server/controllers/activitypub/outbox.ts b/server/controllers/activitypub/outbox.ts
index e060affb2..38b6ec976 100644
--- a/server/controllers/activitypub/outbox.ts
+++ b/server/controllers/activitypub/outbox.ts
@@ -33,7 +33,7 @@ export {
33// --------------------------------------------------------------------------- 33// ---------------------------------------------------------------------------
34 34
35async function outboxController (req: express.Request, res: express.Response) { 35async 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 const actor = accountOrVideoChannel.Actor 37 const actor = accountOrVideoChannel.Actor
38 const actorOutboxUrl = actor.url + '/outbox' 38 const actorOutboxUrl = actor.url + '/outbox'
39 39
diff --git a/server/controllers/api/accounts.ts b/server/controllers/api/accounts.ts
index e24545de8..adbf69781 100644
--- a/server/controllers/api/accounts.ts
+++ b/server/controllers/api/accounts.ts
@@ -17,7 +17,6 @@ import { VideoChannelModel } from '../../models/video/video-channel'
17import { JobQueue } from '../../lib/job-queue' 17import { JobQueue } from '../../lib/job-queue'
18import { logger } from '../../helpers/logger' 18import { logger } from '../../helpers/logger'
19import { VideoPlaylistModel } from '../../models/video/video-playlist' 19import { VideoPlaylistModel } from '../../models/video/video-playlist'
20import { UserModel } from '../../models/account/user'
21import { commonVideoPlaylistFiltersValidator } from '../../middlewares/validators/videos/video-playlists' 20import { commonVideoPlaylistFiltersValidator } from '../../middlewares/validators/videos/video-playlists'
22 21
23const accountsRouter = express.Router() 22const accountsRouter = express.Router()
@@ -71,7 +70,7 @@ export {
71// --------------------------------------------------------------------------- 70// ---------------------------------------------------------------------------
72 71
73function getAccount (req: express.Request, res: express.Response) { 72function getAccount (req: express.Request, res: express.Response) {
74 const account: AccountModel = res.locals.account 73 const account = res.locals.account
75 74
76 if (account.isOutdated()) { 75 if (account.isOutdated()) {
77 JobQueue.Instance.createJob({ type: 'activitypub-refresher', payload: { type: 'actor', url: account.Actor.url } }) 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 // Allow users to see their private/unlisted video playlists 98 // Allow users to see their private/unlisted video playlists
100 let privateAndUnlisted = false 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 privateAndUnlisted = true 101 privateAndUnlisted = true
103 } 102 }
104 103
@@ -116,7 +115,7 @@ async function listAccountPlaylists (req: express.Request, res: express.Response
116} 115}
117 116
118async function listAccountVideos (req: express.Request, res: express.Response) { 117async function listAccountVideos (req: express.Request, res: express.Response) {
119 const account: AccountModel = res.locals.account 118 const account = res.locals.account
120 const followerActorId = isUserAbleToSearchRemoteURI(res) ? null : undefined 119 const followerActorId = isUserAbleToSearchRemoteURI(res) ? null : undefined
121 120
122 const resultList = await VideoModel.listForApi({ 121 const resultList = await VideoModel.listForApi({
diff --git a/server/controllers/api/index.ts b/server/controllers/api/index.ts
index ed4b33dea..60a84036e 100644
--- a/server/controllers/api/index.ts
+++ b/server/controllers/api/index.ts
@@ -41,6 +41,6 @@ export { apiRouter }
41 41
42// --------------------------------------------------------------------------- 42// ---------------------------------------------------------------------------
43 43
44function pong (req: express.Request, res: express.Response, next: express.NextFunction) { 44function pong (req: express.Request, res: express.Response) {
45 return res.send('pong').status(200).end() 45 return res.send('pong').status(200).end()
46} 46}
diff --git a/server/controllers/api/server/follows.ts b/server/controllers/api/server/follows.ts
index 9fa6c34ba..99d211bfc 100644
--- a/server/controllers/api/server/follows.ts
+++ b/server/controllers/api/server/follows.ts
@@ -59,7 +59,7 @@ export {
59 59
60// --------------------------------------------------------------------------- 60// ---------------------------------------------------------------------------
61 61
62async function listFollowing (req: express.Request, res: express.Response, next: express.NextFunction) { 62async function listFollowing (req: express.Request, res: express.Response) {
63 const serverActor = await getServerActor() 63 const serverActor = await getServerActor()
64 const resultList = await ActorFollowModel.listFollowingForApi( 64 const resultList = await ActorFollowModel.listFollowingForApi(
65 serverActor.id, 65 serverActor.id,
@@ -72,7 +72,7 @@ async function listFollowing (req: express.Request, res: express.Response, next:
72 return res.json(getFormattedObjects(resultList.data, resultList.total)) 72 return res.json(getFormattedObjects(resultList.data, resultList.total))
73} 73}
74 74
75async function listFollowers (req: express.Request, res: express.Response, next: express.NextFunction) { 75async function listFollowers (req: express.Request, res: express.Response) {
76 const serverActor = await getServerActor() 76 const serverActor = await getServerActor()
77 const resultList = await ActorFollowModel.listFollowersForApi( 77 const resultList = await ActorFollowModel.listFollowersForApi(
78 serverActor.id, 78 serverActor.id,
@@ -85,7 +85,7 @@ async function listFollowers (req: express.Request, res: express.Response, next:
85 return res.json(getFormattedObjects(resultList.data, resultList.total)) 85 return res.json(getFormattedObjects(resultList.data, resultList.total))
86} 86}
87 87
88async function followInstance (req: express.Request, res: express.Response, next: express.NextFunction) { 88async function followInstance (req: express.Request, res: express.Response) {
89 const hosts = req.body.hosts as string[] 89 const hosts = req.body.hosts as string[]
90 const follower = await getServerActor() 90 const follower = await getServerActor()
91 91
@@ -103,8 +103,8 @@ async function followInstance (req: express.Request, res: express.Response, next
103 return res.status(204).end() 103 return res.status(204).end()
104} 104}
105 105
106async function removeFollow (req: express.Request, res: express.Response, next: express.NextFunction) { 106async function removeFollow (req: express.Request, res: express.Response) {
107 const follow: ActorFollowModel = res.locals.follow 107 const follow = res.locals.follow
108 108
109 await sequelizeTypescript.transaction(async t => { 109 await sequelizeTypescript.transaction(async t => {
110 if (follow.state === 'accepted') await sendUndoFollow(follow, t) 110 if (follow.state === 'accepted') await sendUndoFollow(follow, t)
diff --git a/server/controllers/api/server/redundancy.ts b/server/controllers/api/server/redundancy.ts
index 4140c4991..f8109070d 100644
--- a/server/controllers/api/server/redundancy.ts
+++ b/server/controllers/api/server/redundancy.ts
@@ -2,7 +2,6 @@ import * as express from 'express'
2import { UserRight } from '../../../../shared/models/users' 2import { UserRight } from '../../../../shared/models/users'
3import { asyncMiddleware, authenticate, ensureUserHasRight } from '../../../middlewares' 3import { asyncMiddleware, authenticate, ensureUserHasRight } from '../../../middlewares'
4import { updateServerRedundancyValidator } from '../../../middlewares/validators/redundancy' 4import { updateServerRedundancyValidator } from '../../../middlewares/validators/redundancy'
5import { ServerModel } from '../../../models/server/server'
6import { removeRedundancyOf } from '../../../lib/redundancy' 5import { removeRedundancyOf } from '../../../lib/redundancy'
7import { logger } from '../../../helpers/logger' 6import { logger } from '../../../helpers/logger'
8 7
@@ -23,8 +22,8 @@ export {
23 22
24// --------------------------------------------------------------------------- 23// ---------------------------------------------------------------------------
25 24
26async function updateRedundancy (req: express.Request, res: express.Response, next: express.NextFunction) { 25async function updateRedundancy (req: express.Request, res: express.Response) {
27 const server = res.locals.server as ServerModel 26 const server = res.locals.server
28 27
29 server.redundancyAllowed = req.body.redundancyAllowed 28 server.redundancyAllowed = req.body.redundancyAllowed
30 29
diff --git a/server/controllers/api/server/server-blocklist.ts b/server/controllers/api/server/server-blocklist.ts
index 3cb3a96e2..d165db191 100644
--- a/server/controllers/api/server/server-blocklist.ts
+++ b/server/controllers/api/server/server-blocklist.ts
@@ -18,11 +18,9 @@ import {
18 unblockAccountByServerValidator, 18 unblockAccountByServerValidator,
19 unblockServerByServerValidator 19 unblockServerByServerValidator
20} from '../../../middlewares/validators' 20} from '../../../middlewares/validators'
21import { AccountModel } from '../../../models/account/account'
22import { AccountBlocklistModel } from '../../../models/account/account-blocklist' 21import { AccountBlocklistModel } from '../../../models/account/account-blocklist'
23import { addAccountInBlocklist, addServerInBlocklist, removeAccountFromBlocklist, removeServerFromBlocklist } from '../../../lib/blocklist' 22import { addAccountInBlocklist, addServerInBlocklist, removeAccountFromBlocklist, removeServerFromBlocklist } from '../../../lib/blocklist'
24import { ServerBlocklistModel } from '../../../models/server/server-blocklist' 23import { ServerBlocklistModel } from '../../../models/server/server-blocklist'
25import { ServerModel } from '../../../models/server/server'
26import { UserRight } from '../../../../shared/models/users' 24import { UserRight } from '../../../../shared/models/users'
27 25
28const serverBlocklistRouter = express.Router() 26const serverBlocklistRouter = express.Router()
@@ -91,7 +89,7 @@ async function listBlockedAccounts (req: express.Request, res: express.Response)
91 89
92async function blockAccount (req: express.Request, res: express.Response) { 90async function blockAccount (req: express.Request, res: express.Response) {
93 const serverActor = await getServerActor() 91 const serverActor = await getServerActor()
94 const accountToBlock: AccountModel = res.locals.account 92 const accountToBlock = res.locals.account
95 93
96 await addAccountInBlocklist(serverActor.Account.id, accountToBlock.id) 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
101async function unblockAccount (req: express.Request, res: express.Response) { 99async function unblockAccount (req: express.Request, res: express.Response) {
102 const accountBlock: AccountBlocklistModel = res.locals.accountBlock 100 const accountBlock = res.locals.accountBlock
103 101
104 await removeAccountFromBlocklist(accountBlock) 102 await removeAccountFromBlocklist(accountBlock)
105 103
@@ -116,7 +114,7 @@ async function listBlockedServers (req: express.Request, res: express.Response)
116 114
117async function blockServer (req: express.Request, res: express.Response) { 115async function blockServer (req: express.Request, res: express.Response) {
118 const serverActor = await getServerActor() 116 const serverActor = await getServerActor()
119 const serverToBlock: ServerModel = res.locals.server 117 const serverToBlock = res.locals.server
120 118
121 await addServerInBlocklist(serverActor.Account.id, serverToBlock.id) 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
126async function unblockServer (req: express.Request, res: express.Response) { 124async function unblockServer (req: express.Request, res: express.Response) {
127 const serverBlock: ServerBlocklistModel = res.locals.serverBlock 125 const serverBlock = res.locals.serverBlock
128 126
129 await removeServerFromBlocklist(serverBlock) 127 await removeServerFromBlocklist(serverBlock)
130 128
diff --git a/server/controllers/api/users/index.ts b/server/controllers/api/users/index.ts
index f7edbddf3..2117bdfeb 100644
--- a/server/controllers/api/users/index.ts
+++ b/server/controllers/api/users/index.ts
@@ -221,8 +221,8 @@ async function registerUser (req: express.Request, res: express.Response) {
221 return res.type('json').status(204).end() 221 return res.type('json').status(204).end()
222} 222}
223 223
224async function unblockUser (req: express.Request, res: express.Response, next: express.NextFunction) { 224async function unblockUser (req: express.Request, res: express.Response) {
225 const user: UserModel = res.locals.user 225 const user = res.locals.user
226 226
227 await changeUserBlock(res, user, false) 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
232async function blockUser (req: express.Request, res: express.Response) { 232async function blockUser (req: express.Request, res: express.Response) {
233 const user: UserModel = res.locals.user 233 const user = res.locals.user
234 const reason = req.body.reason 234 const reason = req.body.reason
235 235
236 await changeUserBlock(res, user, true, reason) 236 await changeUserBlock(res, user, true, reason)
@@ -239,7 +239,7 @@ async function blockUser (req: express.Request, res: express.Response) {
239} 239}
240 240
241function getUser (req: express.Request, res: express.Response) { 241function 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
245async function autocompleteUsers (req: express.Request, res: express.Response) { 245async 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
257async function removeUser (req: express.Request, res: express.Response) { 257async function removeUser (req: express.Request, res: express.Response) {
258 const user: UserModel = res.locals.user 258 const user = res.locals.user
259 259
260 await user.destroy() 260 await user.destroy()
261 261
@@ -266,7 +266,7 @@ async function removeUser (req: express.Request, res: express.Response) {
266 266
267async function updateUser (req: express.Request, res: express.Response) { 267async function updateUser (req: express.Request, res: express.Response) {
268 const body: UserUpdate = req.body 268 const body: UserUpdate = req.body
269 const userToUpdate = res.locals.user as UserModel 269 const userToUpdate = res.locals.user
270 const oldUserAuditView = new UserAuditView(userToUpdate.toFormattedJSON()) 270 const oldUserAuditView = new UserAuditView(userToUpdate.toFormattedJSON())
271 const roleChanged = body.role !== undefined && body.role !== userToUpdate.role 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 return res.sendStatus(204) 289 return res.sendStatus(204)
290} 290}
291 291
292async function askResetUserPassword (req: express.Request, res: express.Response, next: express.NextFunction) { 292async function askResetUserPassword (req: express.Request, res: express.Response) {
293 const user = res.locals.user as UserModel 293 const user = res.locals.user
294 294
295 const verificationString = await Redis.Instance.setResetPasswordVerificationString(user.id) 295 const verificationString = await Redis.Instance.setResetPasswordVerificationString(user.id)
296 const url = CONFIG.WEBSERVER.URL + '/reset-password?userId=' + user.id + '&verificationString=' + verificationString 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 return res.status(204).end() 299 return res.status(204).end()
300} 300}
301 301
302async function resetUserPassword (req: express.Request, res: express.Response, next: express.NextFunction) { 302async function resetUserPassword (req: express.Request, res: express.Response) {
303 const user = res.locals.user as UserModel 303 const user = res.locals.user
304 user.password = req.body.password 304 user.password = req.body.password
305 305
306 await user.save() 306 await user.save()
@@ -315,16 +315,16 @@ async function sendVerifyUserEmail (user: UserModel) {
315 return 315 return
316} 316}
317 317
318async function askSendVerifyUserEmail (req: express.Request, res: express.Response, next: express.NextFunction) { 318async function askSendVerifyUserEmail (req: express.Request, res: express.Response) {
319 const user = res.locals.user as UserModel 319 const user = res.locals.user
320 320
321 await sendVerifyUserEmail(user) 321 await sendVerifyUserEmail(user)
322 322
323 return res.status(204).end() 323 return res.status(204).end()
324} 324}
325 325
326async function verifyUserEmail (req: express.Request, res: express.Response, next: express.NextFunction) { 326async function verifyUserEmail (req: express.Request, res: express.Response) {
327 const user = res.locals.user as UserModel 327 const user = res.locals.user
328 user.emailVerified = true 328 user.emailVerified = true
329 329
330 await user.save() 330 await user.save()
@@ -332,7 +332,7 @@ async function verifyUserEmail (req: express.Request, res: express.Response, nex
332 return res.status(204).end() 332 return res.status(204).end()
333} 333}
334 334
335function success (req: express.Request, res: express.Response, next: express.NextFunction) { 335function success (req: express.Request, res: express.Response) {
336 res.end() 336 res.end()
337} 337}
338 338
diff --git a/server/controllers/api/users/me.ts b/server/controllers/api/users/me.ts
index d5e154869..3533499be 100644
--- a/server/controllers/api/users/me.ts
+++ b/server/controllers/api/users/me.ts
@@ -93,8 +93,8 @@ export {
93 93
94// --------------------------------------------------------------------------- 94// ---------------------------------------------------------------------------
95 95
96async function getUserVideos (req: express.Request, res: express.Response, next: express.NextFunction) { 96async function getUserVideos (req: express.Request, res: express.Response) {
97 const user = res.locals.oauth.token.User as UserModel 97 const user = res.locals.oauth.token.User
98 const resultList = await VideoModel.listUserVideosForApi( 98 const resultList = await VideoModel.listUserVideosForApi(
99 user.Account.id, 99 user.Account.id,
100 req.query.start as number, 100 req.query.start as number,
@@ -111,8 +111,8 @@ async function getUserVideos (req: express.Request, res: express.Response, next:
111 return res.json(getFormattedObjects(resultList.data, resultList.total, { additionalAttributes })) 111 return res.json(getFormattedObjects(resultList.data, resultList.total, { additionalAttributes }))
112} 112}
113 113
114async function getUserVideoImports (req: express.Request, res: express.Response, next: express.NextFunction) { 114async function getUserVideoImports (req: express.Request, res: express.Response) {
115 const user = res.locals.oauth.token.User as UserModel 115 const user = res.locals.oauth.token.User
116 const resultList = await VideoImportModel.listUserVideoImportsForApi( 116 const resultList = await VideoImportModel.listUserVideoImportsForApi(
117 user.id, 117 user.id,
118 req.query.start as number, 118 req.query.start as number,
@@ -123,14 +123,14 @@ async function getUserVideoImports (req: express.Request, res: express.Response,
123 return res.json(getFormattedObjects(resultList.data, resultList.total)) 123 return res.json(getFormattedObjects(resultList.data, resultList.total))
124} 124}
125 125
126async function getUserInformation (req: express.Request, res: express.Response, next: express.NextFunction) { 126async function getUserInformation (req: express.Request, res: express.Response) {
127 // We did not load channels in res.locals.user 127 // We did not load channels in res.locals.user
128 const user = await UserModel.loadByUsernameAndPopulateChannels(res.locals.oauth.token.user.username) 128 const user = await UserModel.loadByUsernameAndPopulateChannels(res.locals.oauth.token.user.username)
129 129
130 return res.json(user.toFormattedJSON()) 130 return res.json(user.toFormattedJSON())
131} 131}
132 132
133async function getUserVideoQuotaUsed (req: express.Request, res: express.Response, next: express.NextFunction) { 133async function getUserVideoQuotaUsed (req: express.Request, res: express.Response) {
134 // We did not load channels in res.locals.user 134 // We did not load channels in res.locals.user
135 const user = await UserModel.loadByUsernameAndPopulateChannels(res.locals.oauth.token.user.username) 135 const user = await UserModel.loadByUsernameAndPopulateChannels(res.locals.oauth.token.user.username)
136 const videoQuotaUsed = await UserModel.getOriginalVideoFileTotalFromUser(user) 136 const videoQuotaUsed = await UserModel.getOriginalVideoFileTotalFromUser(user)
@@ -143,7 +143,7 @@ async function getUserVideoQuotaUsed (req: express.Request, res: express.Respons
143 return res.json(data) 143 return res.json(data)
144} 144}
145 145
146async function getUserVideoRating (req: express.Request, res: express.Response, next: express.NextFunction) { 146async function getUserVideoRating (req: express.Request, res: express.Response) {
147 const videoId = res.locals.video.id 147 const videoId = res.locals.video.id
148 const accountId = +res.locals.oauth.token.User.Account.id 148 const accountId = +res.locals.oauth.token.User.Account.id
149 149
@@ -158,7 +158,7 @@ async function getUserVideoRating (req: express.Request, res: express.Response,
158} 158}
159 159
160async function deleteMe (req: express.Request, res: express.Response) { 160async function deleteMe (req: express.Request, res: express.Response) {
161 const user: UserModel = res.locals.oauth.token.User 161 const user = res.locals.oauth.token.User
162 162
163 await user.destroy() 163 await user.destroy()
164 164
@@ -170,7 +170,7 @@ async function deleteMe (req: express.Request, res: express.Response) {
170async function updateMe (req: express.Request, res: express.Response) { 170async function updateMe (req: express.Request, res: express.Response) {
171 const body: UserUpdateMe = req.body 171 const body: UserUpdateMe = req.body
172 172
173 const user: UserModel = res.locals.oauth.token.user 173 const user = res.locals.oauth.token.user
174 const oldUserAuditView = new UserAuditView(user.toFormattedJSON()) 174 const oldUserAuditView = new UserAuditView(user.toFormattedJSON())
175 175
176 if (body.password !== undefined) user.password = body.password 176 if (body.password !== undefined) user.password = body.password
@@ -199,7 +199,7 @@ async function updateMe (req: express.Request, res: express.Response) {
199 199
200async function updateMyAvatar (req: express.Request, res: express.Response) { 200async function updateMyAvatar (req: express.Request, res: express.Response) {
201 const avatarPhysicalFile = req.files[ 'avatarfile' ][ 0 ] 201 const avatarPhysicalFile = req.files[ 'avatarfile' ][ 0 ]
202 const user: UserModel = res.locals.oauth.token.user 202 const user = res.locals.oauth.token.user
203 const oldUserAuditView = new UserAuditView(user.toFormattedJSON()) 203 const oldUserAuditView = new UserAuditView(user.toFormattedJSON())
204 204
205 const userAccount = await AccountModel.load(user.Account.id) 205 const userAccount = await AccountModel.load(user.Account.id)
diff --git a/server/controllers/api/users/my-blocklist.ts b/server/controllers/api/users/my-blocklist.ts
index 9575eab46..481e75139 100644
--- a/server/controllers/api/users/my-blocklist.ts
+++ b/server/controllers/api/users/my-blocklist.ts
@@ -17,7 +17,6 @@ import {
17 serversBlocklistSortValidator, 17 serversBlocklistSortValidator,
18 unblockServerByAccountValidator 18 unblockServerByAccountValidator
19} from '../../../middlewares/validators' 19} from '../../../middlewares/validators'
20import { UserModel } from '../../../models/account/user'
21import { AccountModel } from '../../../models/account/account' 20import { AccountModel } from '../../../models/account/account'
22import { AccountBlocklistModel } from '../../../models/account/account-blocklist' 21import { AccountBlocklistModel } from '../../../models/account/account-blocklist'
23import { addAccountInBlocklist, addServerInBlocklist, removeAccountFromBlocklist, removeServerFromBlocklist } from '../../../lib/blocklist' 22import { addAccountInBlocklist, addServerInBlocklist, removeAccountFromBlocklist, removeServerFromBlocklist } from '../../../lib/blocklist'
@@ -75,7 +74,7 @@ export {
75// --------------------------------------------------------------------------- 74// ---------------------------------------------------------------------------
76 75
77async function listBlockedAccounts (req: express.Request, res: express.Response) { 76async 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 const resultList = await AccountBlocklistModel.listForApi(user.Account.id, req.query.start, req.query.count, req.query.sort) 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
85async function blockAccount (req: express.Request, res: express.Response) { 84async function blockAccount (req: express.Request, res: express.Response) {
86 const user: UserModel = res.locals.oauth.token.User 85 const user = res.locals.oauth.token.User
87 const accountToBlock: AccountModel = res.locals.account 86 const accountToBlock = res.locals.account
88 87
89 await addAccountInBlocklist(user.Account.id, accountToBlock.id) 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
94async function unblockAccount (req: express.Request, res: express.Response) { 93async function unblockAccount (req: express.Request, res: express.Response) {
95 const accountBlock: AccountBlocklistModel = res.locals.accountBlock 94 const accountBlock = res.locals.accountBlock
96 95
97 await removeAccountFromBlocklist(accountBlock) 96 await removeAccountFromBlocklist(accountBlock)
98 97
@@ -100,7 +99,7 @@ async function unblockAccount (req: express.Request, res: express.Response) {
100} 99}
101 100
102async function listBlockedServers (req: express.Request, res: express.Response) { 101async 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 const resultList = await ServerBlocklistModel.listForApi(user.Account.id, req.query.start, req.query.count, req.query.sort) 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
110async function blockServer (req: express.Request, res: express.Response) { 109async function blockServer (req: express.Request, res: express.Response) {
111 const user: UserModel = res.locals.oauth.token.User 110 const user = res.locals.oauth.token.User
112 const serverToBlock: ServerModel = res.locals.server 111 const serverToBlock = res.locals.server
113 112
114 await addServerInBlocklist(user.Account.id, serverToBlock.id) 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
119async function unblockServer (req: express.Request, res: express.Response) { 118async function unblockServer (req: express.Request, res: express.Response) {
120 const serverBlock: ServerBlocklistModel = res.locals.serverBlock 119 const serverBlock = res.locals.serverBlock
121 120
122 await removeServerFromBlocklist(serverBlock) 121 await removeServerFromBlocklist(serverBlock)
123 122
diff --git a/server/controllers/api/users/my-history.ts b/server/controllers/api/users/my-history.ts
index 6cd782c47..b30d3aec2 100644
--- a/server/controllers/api/users/my-history.ts
+++ b/server/controllers/api/users/my-history.ts
@@ -36,7 +36,7 @@ export {
36// --------------------------------------------------------------------------- 36// ---------------------------------------------------------------------------
37 37
38async function listMyVideosHistory (req: express.Request, res: express.Response) { 38async 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 const resultList = await UserVideoHistoryModel.listForApi(user, req.query.start, req.query.count) 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
46async function removeUserHistory (req: express.Request, res: express.Response) { 46async 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 const beforeDate = req.body.beforeDate || null 48 const beforeDate = req.body.beforeDate || null
49 49
50 await sequelizeTypescript.transaction(t => { 50 await sequelizeTypescript.transaction(t => {
diff --git a/server/controllers/api/users/my-notifications.ts b/server/controllers/api/users/my-notifications.ts
index 76cf97587..bbafda5a6 100644
--- a/server/controllers/api/users/my-notifications.ts
+++ b/server/controllers/api/users/my-notifications.ts
@@ -9,7 +9,6 @@ import {
9 setDefaultSort, 9 setDefaultSort,
10 userNotificationsSortValidator 10 userNotificationsSortValidator
11} from '../../../middlewares' 11} from '../../../middlewares'
12import { UserModel } from '../../../models/account/user'
13import { getFormattedObjects } from '../../../helpers/utils' 12import { getFormattedObjects } from '../../../helpers/utils'
14import { UserNotificationModel } from '../../../models/account/user-notification' 13import { UserNotificationModel } from '../../../models/account/user-notification'
15import { meRouter } from './me' 14import { meRouter } from './me'
@@ -57,8 +56,8 @@ export {
57// --------------------------------------------------------------------------- 56// ---------------------------------------------------------------------------
58 57
59async function updateNotificationSettings (req: express.Request, res: express.Response) { 58async function updateNotificationSettings (req: express.Request, res: express.Response) {
60 const user: UserModel = res.locals.oauth.token.User 59 const user = res.locals.oauth.token.User
61 const body = req.body 60 const body = req.body as UserNotificationSetting
62 61
63 const query = { 62 const query = {
64 where: { 63 where: {
@@ -84,7 +83,7 @@ async function updateNotificationSettings (req: express.Request, res: express.Re
84} 83}
85 84
86async function listUserNotifications (req: express.Request, res: express.Response) { 85async 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 const resultList = await UserNotificationModel.listForApi(user.id, req.query.start, req.query.count, req.query.sort, req.query.unread) 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
94async function markAsReadUserNotifications (req: express.Request, res: express.Response) { 93async 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 await UserNotificationModel.markAsRead(user.id, req.body.ids) 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
102async function markAsReadAllUserNotifications (req: express.Request, res: express.Response) { 101async 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 await UserNotificationModel.markAllAsRead(user.id) 104 await UserNotificationModel.markAllAsRead(user.id)
106 105
diff --git a/server/controllers/api/users/my-subscriptions.ts b/server/controllers/api/users/my-subscriptions.ts
index accca6d52..a173adfd0 100644
--- a/server/controllers/api/users/my-subscriptions.ts
+++ b/server/controllers/api/users/my-subscriptions.ts
@@ -14,7 +14,6 @@ import {
14 userSubscriptionGetValidator 14 userSubscriptionGetValidator
15} from '../../../middlewares' 15} from '../../../middlewares'
16import { areSubscriptionsExistValidator, userSubscriptionsSortValidator, videosSortValidator } from '../../../middlewares/validators' 16import { areSubscriptionsExistValidator, userSubscriptionsSortValidator, videosSortValidator } from '../../../middlewares/validators'
17import { UserModel } from '../../../models/account/user'
18import { VideoModel } from '../../../models/video/video' 17import { VideoModel } from '../../../models/video/video'
19import { buildNSFWFilter } from '../../../helpers/express-utils' 18import { buildNSFWFilter } from '../../../helpers/express-utils'
20import { VideoFilter } from '../../../../shared/models/videos/video-query.type' 19import { VideoFilter } from '../../../../shared/models/videos/video-query.type'
@@ -77,7 +76,7 @@ export {
77 76
78async function areSubscriptionsExist (req: express.Request, res: express.Response) { 77async function areSubscriptionsExist (req: express.Request, res: express.Response) {
79 const uris = req.query.uris as string[] 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 const handles = uris.map(u => { 81 const handles = uris.map(u => {
83 let [ name, host ] = u.split('@') 82 let [ name, host ] = u.split('@')
@@ -107,7 +106,7 @@ async function areSubscriptionsExist (req: express.Request, res: express.Respons
107} 106}
108 107
109async function addUserSubscription (req: express.Request, res: express.Response) { 108async 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 const [ name, host ] = req.body.uri.split('@') 110 const [ name, host ] = req.body.uri.split('@')
112 111
113 const payload = { 112 const payload = {
@@ -123,13 +122,13 @@ async function addUserSubscription (req: express.Request, res: express.Response)
123} 122}
124 123
125function getUserSubscription (req: express.Request, res: express.Response) { 124function getUserSubscription (req: express.Request, res: express.Response) {
126 const subscription: ActorFollowModel = res.locals.subscription 125 const subscription = res.locals.subscription
127 126
128 return res.json(subscription.ActorFollowing.VideoChannel.toFormattedJSON()) 127 return res.json(subscription.ActorFollowing.VideoChannel.toFormattedJSON())
129} 128}
130 129
131async function deleteUserSubscription (req: express.Request, res: express.Response) { 130async function deleteUserSubscription (req: express.Request, res: express.Response) {
132 const subscription: ActorFollowModel = res.locals.subscription 131 const subscription = res.locals.subscription
133 132
134 await sequelizeTypescript.transaction(async t => { 133 await sequelizeTypescript.transaction(async t => {
135 return subscription.destroy({ transaction: t }) 134 return subscription.destroy({ transaction: t })
@@ -139,7 +138,7 @@ async function deleteUserSubscription (req: express.Request, res: express.Respon
139} 138}
140 139
141async function getUserSubscriptions (req: express.Request, res: express.Response) { 140async 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 const actorId = user.Account.Actor.id 142 const actorId = user.Account.Actor.id
144 143
145 const resultList = await ActorFollowModel.listSubscriptionsForApi(actorId, req.query.start, req.query.count, req.query.sort) 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 return res.json(getFormattedObjects(resultList.data, resultList.total)) 146 return res.json(getFormattedObjects(resultList.data, resultList.total))
148} 147}
149 148
150async function getUserSubscriptionVideos (req: express.Request, res: express.Response, next: express.NextFunction) { 149async function getUserSubscriptionVideos (req: express.Request, res: express.Response) {
151 const user = res.locals.oauth.token.User as UserModel 150 const user = res.locals.oauth.token.User
152 const resultList = await VideoModel.listForApi({ 151 const resultList = await VideoModel.listForApi({
153 start: req.query.start, 152 start: req.query.start,
154 count: req.query.count, 153 count: req.query.count,
diff --git a/server/controllers/api/users/my-video-playlists.ts b/server/controllers/api/users/my-video-playlists.ts
index 42da02bff..15e92f4f3 100644
--- a/server/controllers/api/users/my-video-playlists.ts
+++ b/server/controllers/api/users/my-video-playlists.ts
@@ -1,6 +1,5 @@
1import * as express from 'express' 1import * as express from 'express'
2import { asyncMiddleware, authenticate } from '../../../middlewares' 2import { asyncMiddleware, authenticate } from '../../../middlewares'
3import { UserModel } from '../../../models/account/user'
4import { doVideosInPlaylistExistValidator } from '../../../middlewares/validators/videos/video-playlists' 3import { doVideosInPlaylistExistValidator } from '../../../middlewares/validators/videos/video-playlists'
5import { VideoPlaylistModel } from '../../../models/video/video-playlist' 4import { VideoPlaylistModel } from '../../../models/video/video-playlist'
6import { VideoExistInPlaylist } from '../../../../shared/models/videos/playlist/video-exist-in-playlist.model' 5import { VideoExistInPlaylist } from '../../../../shared/models/videos/playlist/video-exist-in-playlist.model'
@@ -23,7 +22,7 @@ export {
23 22
24async function doVideosInPlaylistExist (req: express.Request, res: express.Response) { 23async function doVideosInPlaylistExist (req: express.Request, res: express.Response) {
25 const videoIds = req.query.videoIds.map(i => parseInt(i + '', 10)) 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 const results = await VideoPlaylistModel.listPlaylistIdsOf(user.Account.id, videoIds) 27 const results = await VideoPlaylistModel.listPlaylistIdsOf(user.Account.id, videoIds)
29 28
diff --git a/server/controllers/api/video-channel.ts b/server/controllers/api/video-channel.ts
index c13aed4dc..5881cab41 100644
--- a/server/controllers/api/video-channel.ts
+++ b/server/controllers/api/video-channel.ts
@@ -30,7 +30,6 @@ import { updateAvatarValidator } from '../../middlewares/validators/avatar'
30import { updateActorAvatarFile } from '../../lib/avatar' 30import { updateActorAvatarFile } from '../../lib/avatar'
31import { auditLoggerFactory, getAuditIdFromRes, VideoChannelAuditView } from '../../helpers/audit-logger' 31import { auditLoggerFactory, getAuditIdFromRes, VideoChannelAuditView } from '../../helpers/audit-logger'
32import { resetSequelizeInstance } from '../../helpers/database-utils' 32import { resetSequelizeInstance } from '../../helpers/database-utils'
33import { UserModel } from '../../models/account/user'
34import { JobQueue } from '../../lib/job-queue' 33import { JobQueue } from '../../lib/job-queue'
35import { VideoPlaylistModel } from '../../models/video/video-playlist' 34import { VideoPlaylistModel } from '../../models/video/video-playlist'
36import { commonVideoPlaylistFiltersValidator } from '../../middlewares/validators/videos/video-playlists' 35import { commonVideoPlaylistFiltersValidator } from '../../middlewares/validators/videos/video-playlists'
@@ -109,16 +108,16 @@ export {
109 108
110// --------------------------------------------------------------------------- 109// ---------------------------------------------------------------------------
111 110
112async function listVideoChannels (req: express.Request, res: express.Response, next: express.NextFunction) { 111async function listVideoChannels (req: express.Request, res: express.Response) {
113 const serverActor = await getServerActor() 112 const serverActor = await getServerActor()
114 const resultList = await VideoChannelModel.listForApi(serverActor.id, req.query.start, req.query.count, req.query.sort) 113 const resultList = await VideoChannelModel.listForApi(serverActor.id, req.query.start, req.query.count, req.query.sort)
115 114
116 return res.json(getFormattedObjects(resultList.data, resultList.total)) 115 return res.json(getFormattedObjects(resultList.data, resultList.total))
117} 116}
118 117
119async function updateVideoChannelAvatar (req: express.Request, res: express.Response, next: express.NextFunction) { 118async function updateVideoChannelAvatar (req: express.Request, res: express.Response) {
120 const avatarPhysicalFile = req.files[ 'avatarfile' ][ 0 ] 119 const avatarPhysicalFile = req.files[ 'avatarfile' ][ 0 ]
121 const videoChannel = res.locals.videoChannel as VideoChannelModel 120 const videoChannel = res.locals.videoChannel
122 const oldVideoChannelAuditKeys = new VideoChannelAuditView(videoChannel.toFormattedJSON()) 121 const oldVideoChannelAuditKeys = new VideoChannelAuditView(videoChannel.toFormattedJSON())
123 122
124 const avatar = await updateActorAvatarFile(avatarPhysicalFile, videoChannel) 123 const avatar = await updateActorAvatarFile(avatarPhysicalFile, videoChannel)
@@ -136,7 +135,7 @@ async function addVideoChannel (req: express.Request, res: express.Response) {
136 const videoChannelInfo: VideoChannelCreate = req.body 135 const videoChannelInfo: VideoChannelCreate = req.body
137 136
138 const videoChannelCreated: VideoChannelModel = await sequelizeTypescript.transaction(async t => { 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 return createVideoChannel(videoChannelInfo, account, t) 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
158async function updateVideoChannel (req: express.Request, res: express.Response) { 157async function updateVideoChannel (req: express.Request, res: express.Response) {
159 const videoChannelInstance = res.locals.videoChannel as VideoChannelModel 158 const videoChannelInstance = res.locals.videoChannel
160 const videoChannelFieldsSave = videoChannelInstance.toJSON() 159 const videoChannelFieldsSave = videoChannelInstance.toJSON()
161 const oldVideoChannelAuditKeys = new VideoChannelAuditView(videoChannelInstance.toFormattedJSON()) 160 const oldVideoChannelAuditKeys = new VideoChannelAuditView(videoChannelInstance.toFormattedJSON())
162 const videoChannelInfoToUpdate = req.body as VideoChannelUpdate 161 const videoChannelInfoToUpdate = req.body as VideoChannelUpdate
@@ -196,7 +195,7 @@ async function updateVideoChannel (req: express.Request, res: express.Response)
196} 195}
197 196
198async function removeVideoChannel (req: express.Request, res: express.Response) { 197async function removeVideoChannel (req: express.Request, res: express.Response) {
199 const videoChannelInstance: VideoChannelModel = res.locals.videoChannel 198 const videoChannelInstance = res.locals.videoChannel
200 199
201 await sequelizeTypescript.transaction(async t => { 200 await sequelizeTypescript.transaction(async t => {
202 await VideoPlaylistModel.resetPlaylistsOfChannel(videoChannelInstance.id, t) 201 await VideoPlaylistModel.resetPlaylistsOfChannel(videoChannelInstance.id, t)
@@ -210,7 +209,7 @@ async function removeVideoChannel (req: express.Request, res: express.Response)
210 return res.type('json').status(204).end() 209 return res.type('json').status(204).end()
211} 210}
212 211
213async function getVideoChannel (req: express.Request, res: express.Response, next: express.NextFunction) { 212async function getVideoChannel (req: express.Request, res: express.Response) {
214 const videoChannelWithVideos = await VideoChannelModel.loadAndPopulateAccountAndVideos(res.locals.videoChannel.id) 213 const videoChannelWithVideos = await VideoChannelModel.loadAndPopulateAccountAndVideos(res.locals.videoChannel.id)
215 214
216 if (videoChannelWithVideos.isOutdated()) { 215 if (videoChannelWithVideos.isOutdated()) {
@@ -236,8 +235,8 @@ async function listVideoChannelPlaylists (req: express.Request, res: express.Res
236 return res.json(getFormattedObjects(resultList.data, resultList.total)) 235 return res.json(getFormattedObjects(resultList.data, resultList.total))
237} 236}
238 237
239async function listVideoChannelVideos (req: express.Request, res: express.Response, next: express.NextFunction) { 238async function listVideoChannelVideos (req: express.Request, res: express.Response) {
240 const videoChannelInstance: VideoChannelModel = res.locals.videoChannel 239 const videoChannelInstance = res.locals.videoChannel
241 const followerActorId = isUserAbleToSearchRemoteURI(res) ? null : undefined 240 const followerActorId = isUserAbleToSearchRemoteURI(res) ? null : undefined
242 241
243 const resultList = await VideoModel.listForApi({ 242 const resultList = await VideoModel.listForApi({
diff --git a/server/controllers/api/video-playlist.ts b/server/controllers/api/video-playlist.ts
index c7dfc583b..5b1601c4e 100644
--- a/server/controllers/api/video-playlist.ts
+++ b/server/controllers/api/video-playlist.ts
@@ -10,7 +10,6 @@ import {
10 setDefaultPagination, 10 setDefaultPagination,
11 setDefaultSort 11 setDefaultSort
12} from '../../middlewares' 12} from '../../middlewares'
13import { VideoChannelModel } from '../../models/video/video-channel'
14import { videoPlaylistsSortValidator } from '../../middlewares/validators' 13import { videoPlaylistsSortValidator } from '../../middlewares/validators'
15import { buildNSFWFilter, createReqFiles, isUserAbleToSearchRemoteURI } from '../../helpers/express-utils' 14import { buildNSFWFilter, createReqFiles, isUserAbleToSearchRemoteURI } from '../../helpers/express-utils'
16import { CONFIG, MIMETYPES, sequelizeTypescript, THUMBNAILS_SIZE, VIDEO_PLAYLIST_PRIVACIES } from '../../initializers' 15import { CONFIG, MIMETYPES, sequelizeTypescript, THUMBNAILS_SIZE, VIDEO_PLAYLIST_PRIVACIES } from '../../initializers'
@@ -31,7 +30,6 @@ import { VideoPlaylistCreate } from '../../../shared/models/videos/playlist/vide
31import { VideoPlaylistPrivacy } from '../../../shared/models/videos/playlist/video-playlist-privacy.model' 30import { VideoPlaylistPrivacy } from '../../../shared/models/videos/playlist/video-playlist-privacy.model'
32import { processImage } from '../../helpers/image-utils' 31import { processImage } from '../../helpers/image-utils'
33import { join } from 'path' 32import { join } from 'path'
34import { UserModel } from '../../models/account/user'
35import { sendCreateVideoPlaylist, sendDeleteVideoPlaylist, sendUpdateVideoPlaylist } from '../../lib/activitypub/send' 33import { sendCreateVideoPlaylist, sendDeleteVideoPlaylist, sendUpdateVideoPlaylist } from '../../lib/activitypub/send'
36import { getVideoPlaylistActivityPubUrl, getVideoPlaylistElementActivityPubUrl } from '../../lib/activitypub/url' 34import { getVideoPlaylistActivityPubUrl, getVideoPlaylistElementActivityPubUrl } from '../../lib/activitypub/url'
37import { VideoPlaylistUpdate } from '../../../shared/models/videos/playlist/video-playlist-update.model' 35import { 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
144function getVideoPlaylist (req: express.Request, res: express.Response) { 142function getVideoPlaylist (req: express.Request, res: express.Response) {
145 const videoPlaylist = res.locals.videoPlaylist as VideoPlaylistModel 143 const videoPlaylist = res.locals.videoPlaylist
146 144
147 return res.json(videoPlaylist.toFormattedJSON()) 145 return res.json(videoPlaylist.toFormattedJSON())
148} 146}
149 147
150async function addVideoPlaylist (req: express.Request, res: express.Response) { 148async function addVideoPlaylist (req: express.Request, res: express.Response) {
151 const videoPlaylistInfo: VideoPlaylistCreate = req.body 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 const videoPlaylist = new VideoPlaylistModel({ 152 const videoPlaylist = new VideoPlaylistModel({
155 name: videoPlaylistInfo.displayName, 153 name: videoPlaylistInfo.displayName,
@@ -161,7 +159,7 @@ async function addVideoPlaylist (req: express.Request, res: express.Response) {
161 videoPlaylist.url = getVideoPlaylistActivityPubUrl(videoPlaylist) // We use the UUID, so set the URL after building the object 159 videoPlaylist.url = getVideoPlaylistActivityPubUrl(videoPlaylist) // We use the UUID, so set the URL after building the object
162 160
163 if (videoPlaylistInfo.videoChannelId) { 161 if (videoPlaylistInfo.videoChannelId) {
164 const videoChannel = res.locals.videoChannel as VideoChannelModel 162 const videoChannel = res.locals.videoChannel
165 163
166 videoPlaylist.videoChannelId = videoChannel.id 164 videoPlaylist.videoChannelId = videoChannel.id
167 videoPlaylist.VideoChannel = videoChannel 165 videoPlaylist.VideoChannel = videoChannel
@@ -194,7 +192,7 @@ async function addVideoPlaylist (req: express.Request, res: express.Response) {
194} 192}
195 193
196async function updateVideoPlaylist (req: express.Request, res: express.Response) { 194async function updateVideoPlaylist (req: express.Request, res: express.Response) {
197 const videoPlaylistInstance = res.locals.videoPlaylist as VideoPlaylistModel 195 const videoPlaylistInstance = res.locals.videoPlaylist
198 const videoPlaylistFieldsSave = videoPlaylistInstance.toJSON() 196 const videoPlaylistFieldsSave = videoPlaylistInstance.toJSON()
199 const videoPlaylistInfoToUpdate = req.body as VideoPlaylistUpdate 197 const videoPlaylistInfoToUpdate = req.body as VideoPlaylistUpdate
200 const wasPrivatePlaylist = videoPlaylistInstance.privacy === VideoPlaylistPrivacy.PRIVATE 198 const wasPrivatePlaylist = videoPlaylistInstance.privacy === VideoPlaylistPrivacy.PRIVATE
@@ -219,7 +217,7 @@ async function updateVideoPlaylist (req: express.Request, res: express.Response)
219 if (videoPlaylistInfoToUpdate.videoChannelId === null) { 217 if (videoPlaylistInfoToUpdate.videoChannelId === null) {
220 videoPlaylistInstance.videoChannelId = null 218 videoPlaylistInstance.videoChannelId = null
221 } else { 219 } else {
222 const videoChannel = res.locals.videoChannel as VideoChannelModel 220 const videoChannel = res.locals.videoChannel
223 221
224 videoPlaylistInstance.videoChannelId = videoChannel.id 222 videoPlaylistInstance.videoChannelId = videoChannel.id
225 videoPlaylistInstance.VideoChannel = videoChannel 223 videoPlaylistInstance.VideoChannel = videoChannel
@@ -262,7 +260,7 @@ async function updateVideoPlaylist (req: express.Request, res: express.Response)
262} 260}
263 261
264async function removeVideoPlaylist (req: express.Request, res: express.Response) { 262async function removeVideoPlaylist (req: express.Request, res: express.Response) {
265 const videoPlaylistInstance: VideoPlaylistModel = res.locals.videoPlaylist 263 const videoPlaylistInstance = res.locals.videoPlaylist
266 264
267 await sequelizeTypescript.transaction(async t => { 265 await sequelizeTypescript.transaction(async t => {
268 await videoPlaylistInstance.destroy({ transaction: t }) 266 await videoPlaylistInstance.destroy({ transaction: t })
@@ -277,8 +275,8 @@ async function removeVideoPlaylist (req: express.Request, res: express.Response)
277 275
278async function addVideoInPlaylist (req: express.Request, res: express.Response) { 276async function addVideoInPlaylist (req: express.Request, res: express.Response) {
279 const body: VideoPlaylistElementCreate = req.body 277 const body: VideoPlaylistElementCreate = req.body
280 const videoPlaylist: VideoPlaylistModel = res.locals.videoPlaylist 278 const videoPlaylist = res.locals.videoPlaylist
281 const video: VideoModel = res.locals.video 279 const video = res.locals.video
282 280
283 const playlistElement: VideoPlaylistElementModel = await sequelizeTypescript.transaction(async t => { 281 const playlistElement: VideoPlaylistElementModel = await sequelizeTypescript.transaction(async t => {
284 const position = await VideoPlaylistElementModel.getNextPositionOf(videoPlaylist.id, t) 282 const position = await VideoPlaylistElementModel.getNextPositionOf(videoPlaylist.id, t)
@@ -323,8 +321,8 @@ async function addVideoInPlaylist (req: express.Request, res: express.Response)
323 321
324async function updateVideoPlaylistElement (req: express.Request, res: express.Response) { 322async function updateVideoPlaylistElement (req: express.Request, res: express.Response) {
325 const body: VideoPlaylistElementUpdate = req.body 323 const body: VideoPlaylistElementUpdate = req.body
326 const videoPlaylist: VideoPlaylistModel = res.locals.videoPlaylist 324 const videoPlaylist = res.locals.videoPlaylist
327 const videoPlaylistElement: VideoPlaylistElementModel = res.locals.videoPlaylistElement 325 const videoPlaylistElement = res.locals.videoPlaylistElement
328 326
329 const playlistElement: VideoPlaylistElementModel = await sequelizeTypescript.transaction(async t => { 327 const playlistElement: VideoPlaylistElementModel = await sequelizeTypescript.transaction(async t => {
330 if (body.startTimestamp !== undefined) videoPlaylistElement.startTimestamp = body.startTimestamp 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
348async function removeVideoFromPlaylist (req: express.Request, res: express.Response) { 346async function removeVideoFromPlaylist (req: express.Request, res: express.Response) {
349 const videoPlaylistElement: VideoPlaylistElementModel = res.locals.videoPlaylistElement 347 const videoPlaylistElement = res.locals.videoPlaylistElement
350 const videoPlaylist: VideoPlaylistModel = res.locals.videoPlaylist 348 const videoPlaylist = res.locals.videoPlaylist
351 const positionToDelete = videoPlaylistElement.position 349 const positionToDelete = videoPlaylistElement.position
352 350
353 await sequelizeTypescript.transaction(async t => { 351 await sequelizeTypescript.transaction(async t => {
@@ -368,7 +366,7 @@ async function removeVideoFromPlaylist (req: express.Request, res: express.Respo
368} 366}
369 367
370async function reorderVideosPlaylist (req: express.Request, res: express.Response) { 368async function reorderVideosPlaylist (req: express.Request, res: express.Response) {
371 const videoPlaylist: VideoPlaylistModel = res.locals.videoPlaylist 369 const videoPlaylist = res.locals.videoPlaylist
372 const body: VideoPlaylistReorder = req.body 370 const body: VideoPlaylistReorder = req.body
373 371
374 const start: number = body.startPosition 372 const start: number = body.startPosition
@@ -416,7 +414,7 @@ async function reorderVideosPlaylist (req: express.Request, res: express.Respons
416} 414}
417 415
418async function getVideoPlaylistVideos (req: express.Request, res: express.Response) { 416async function getVideoPlaylistVideos (req: express.Request, res: express.Response) {
419 const videoPlaylistInstance: VideoPlaylistModel = res.locals.videoPlaylist 417 const videoPlaylistInstance = res.locals.videoPlaylist
420 const followerActorId = isUserAbleToSearchRemoteURI(res) ? null : undefined 418 const followerActorId = isUserAbleToSearchRemoteURI(res) ? null : undefined
421 419
422 const resultList = await VideoModel.listForApi({ 420 const resultList = await VideoModel.listForApi({
diff --git a/server/controllers/api/videos/abuse.ts b/server/controllers/api/videos/abuse.ts
index 32f9c4793..ca70230a2 100644
--- a/server/controllers/api/videos/abuse.ts
+++ b/server/controllers/api/videos/abuse.ts
@@ -17,10 +17,8 @@ import {
17 videoAbuseUpdateValidator 17 videoAbuseUpdateValidator
18} from '../../../middlewares' 18} from '../../../middlewares'
19import { AccountModel } from '../../../models/account/account' 19import { AccountModel } from '../../../models/account/account'
20import { VideoModel } from '../../../models/video/video'
21import { VideoAbuseModel } from '../../../models/video/video-abuse' 20import { VideoAbuseModel } from '../../../models/video/video-abuse'
22import { auditLoggerFactory, VideoAbuseAuditView } from '../../../helpers/audit-logger' 21import { auditLoggerFactory, VideoAbuseAuditView } from '../../../helpers/audit-logger'
23import { UserModel } from '../../../models/account/user'
24import { Notifier } from '../../../lib/notifier' 22import { Notifier } from '../../../lib/notifier'
25import { sendVideoAbuse } from '../../../lib/activitypub/send/send-flag' 23import { 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
71async function updateVideoAbuse (req: express.Request, res: express.Response) { 69async function updateVideoAbuse (req: express.Request, res: express.Response) {
72 const videoAbuse: VideoAbuseModel = res.locals.videoAbuse 70 const videoAbuse = res.locals.videoAbuse
73 71
74 if (req.body.moderationComment !== undefined) videoAbuse.moderationComment = req.body.moderationComment 72 if (req.body.moderationComment !== undefined) videoAbuse.moderationComment = req.body.moderationComment
75 if (req.body.state !== undefined) videoAbuse.state = req.body.state 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
86async function deleteVideoAbuse (req: express.Request, res: express.Response) { 84async function deleteVideoAbuse (req: express.Request, res: express.Response) {
87 const videoAbuse: VideoAbuseModel = res.locals.videoAbuse 85 const videoAbuse = res.locals.videoAbuse
88 86
89 await sequelizeTypescript.transaction(t => { 87 await sequelizeTypescript.transaction(t => {
90 return videoAbuse.destroy({ transaction: t }) 88 return videoAbuse.destroy({ transaction: t })
@@ -96,11 +94,11 @@ async function deleteVideoAbuse (req: express.Request, res: express.Response) {
96} 94}
97 95
98async function reportVideoAbuse (req: express.Request, res: express.Response) { 96async function reportVideoAbuse (req: express.Request, res: express.Response) {
99 const videoInstance = res.locals.video as VideoModel 97 const videoInstance = res.locals.video
100 const body: VideoAbuseCreate = req.body 98 const body: VideoAbuseCreate = req.body
101 99
102 const videoAbuse: VideoAbuseModel = await sequelizeTypescript.transaction(async t => { 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 const abuseToCreate = { 103 const abuseToCreate = {
106 reporterAccountId: reporterAccount.id, 104 reporterAccountId: reporterAccount.id,
diff --git a/server/controllers/api/videos/blacklist.ts b/server/controllers/api/videos/blacklist.ts
index b01296200..d0728eb59 100644
--- a/server/controllers/api/videos/blacklist.ts
+++ b/server/controllers/api/videos/blacklist.ts
@@ -17,7 +17,6 @@ import {
17import { VideoBlacklistModel } from '../../../models/video/video-blacklist' 17import { VideoBlacklistModel } from '../../../models/video/video-blacklist'
18import { sequelizeTypescript } from '../../../initializers' 18import { sequelizeTypescript } from '../../../initializers'
19import { Notifier } from '../../../lib/notifier' 19import { Notifier } from '../../../lib/notifier'
20import { VideoModel } from '../../../models/video/video'
21import { sendDeleteVideo } from '../../../lib/activitypub/send' 20import { sendDeleteVideo } from '../../../lib/activitypub/send'
22import { federateVideoIfNeeded } from '../../../lib/activitypub' 21import { federateVideoIfNeeded } from '../../../lib/activitypub'
23 22
@@ -87,7 +86,7 @@ async function addVideoToBlacklist (req: express.Request, res: express.Response)
87} 86}
88 87
89async function updateVideoBlacklistController (req: express.Request, res: express.Response) { 88async 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 if (req.body.reason !== undefined) videoBlacklist.reason = req.body.reason 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
107async function removeVideoFromBlacklistController (req: express.Request, res: express.Response, next: express.NextFunction) { 106async function removeVideoFromBlacklistController (req: express.Request, res: express.Response, next: express.NextFunction) {
108 const videoBlacklist = res.locals.videoBlacklist as VideoBlacklistModel 107 const videoBlacklist = res.locals.videoBlacklist
109 const video: VideoModel = res.locals.video 108 const video = res.locals.video
110 109
111 await sequelizeTypescript.transaction(async t => { 110 await sequelizeTypescript.transaction(async t => {
112 const unfederated = videoBlacklist.unfederated 111 const unfederated = videoBlacklist.unfederated
diff --git a/server/controllers/api/videos/captions.ts b/server/controllers/api/videos/captions.ts
index 9b3661368..2694577d8 100644
--- a/server/controllers/api/videos/captions.ts
+++ b/server/controllers/api/videos/captions.ts
@@ -5,7 +5,6 @@ import { createReqFiles } from '../../../helpers/express-utils'
5import { CONFIG, MIMETYPES, sequelizeTypescript } from '../../../initializers' 5import { CONFIG, MIMETYPES, sequelizeTypescript } from '../../../initializers'
6import { getFormattedObjects } from '../../../helpers/utils' 6import { getFormattedObjects } from '../../../helpers/utils'
7import { VideoCaptionModel } from '../../../models/video/video-caption' 7import { VideoCaptionModel } from '../../../models/video/video-caption'
8import { VideoModel } from '../../../models/video/video'
9import { logger } from '../../../helpers/logger' 8import { logger } from '../../../helpers/logger'
10import { federateVideoIfNeeded } from '../../../lib/activitypub' 9import { federateVideoIfNeeded } from '../../../lib/activitypub'
11import { moveAndProcessCaptionFile } from '../../../helpers/captions-utils' 10import { moveAndProcessCaptionFile } from '../../../helpers/captions-utils'
@@ -52,7 +51,7 @@ async function listVideoCaptions (req: express.Request, res: express.Response) {
52 51
53async function addVideoCaption (req: express.Request, res: express.Response) { 52async function addVideoCaption (req: express.Request, res: express.Response) {
54 const videoCaptionPhysicalFile = req.files['captionfile'][0] 53 const videoCaptionPhysicalFile = req.files['captionfile'][0]
55 const video = res.locals.video as VideoModel 54 const video = res.locals.video
56 55
57 const videoCaption = new VideoCaptionModel({ 56 const videoCaption = new VideoCaptionModel({
58 videoId: video.id, 57 videoId: video.id,
@@ -74,8 +73,8 @@ async function addVideoCaption (req: express.Request, res: express.Response) {
74} 73}
75 74
76async function deleteVideoCaption (req: express.Request, res: express.Response) { 75async function deleteVideoCaption (req: express.Request, res: express.Response) {
77 const video = res.locals.video as VideoModel 76 const video = res.locals.video
78 const videoCaption = res.locals.videoCaption as VideoCaptionModel 77 const videoCaption = res.locals.videoCaption
79 78
80 await sequelizeTypescript.transaction(async t => { 79 await sequelizeTypescript.transaction(async t => {
81 await videoCaption.destroy({ transaction: t }) 80 await videoCaption.destroy({ transaction: t })
diff --git a/server/controllers/api/videos/comment.ts b/server/controllers/api/videos/comment.ts
index 70c1148ba..176ee8bd4 100644
--- a/server/controllers/api/videos/comment.ts
+++ b/server/controllers/api/videos/comment.ts
@@ -8,7 +8,8 @@ import { buildFormattedCommentTree, createVideoComment } from '../../../lib/vide
8import { 8import {
9 asyncMiddleware, 9 asyncMiddleware,
10 asyncRetryTransactionMiddleware, 10 asyncRetryTransactionMiddleware,
11 authenticate, optionalAuthenticate, 11 authenticate,
12 optionalAuthenticate,
12 paginationValidator, 13 paginationValidator,
13 setDefaultPagination, 14 setDefaultPagination,
14 setDefaultSort 15 setDefaultSort
@@ -21,11 +22,9 @@ import {
21 removeVideoCommentValidator, 22 removeVideoCommentValidator,
22 videoCommentThreadsSortValidator 23 videoCommentThreadsSortValidator
23} from '../../../middlewares/validators' 24} from '../../../middlewares/validators'
24import { VideoModel } from '../../../models/video/video'
25import { VideoCommentModel } from '../../../models/video/video-comment' 25import { VideoCommentModel } from '../../../models/video/video-comment'
26import { auditLoggerFactory, CommentAuditView, getAuditIdFromRes } from '../../../helpers/audit-logger' 26import { auditLoggerFactory, CommentAuditView, getAuditIdFromRes } from '../../../helpers/audit-logger'
27import { AccountModel } from '../../../models/account/account' 27import { AccountModel } from '../../../models/account/account'
28import { UserModel } from '../../../models/account/user'
29import { Notifier } from '../../../lib/notifier' 28import { Notifier } from '../../../lib/notifier'
30 29
31const auditLogger = auditLoggerFactory('comments') 30const auditLogger = auditLoggerFactory('comments')
@@ -70,9 +69,9 @@ export {
70 69
71// --------------------------------------------------------------------------- 70// ---------------------------------------------------------------------------
72 71
73async function listVideoThreads (req: express.Request, res: express.Response, next: express.NextFunction) { 72async function listVideoThreads (req: express.Request, res: express.Response) {
74 const video = res.locals.video as VideoModel 73 const video = res.locals.video
75 const user: UserModel = res.locals.oauth ? res.locals.oauth.token.User : undefined 74 const user = res.locals.oauth ? res.locals.oauth.token.User : undefined
76 75
77 let resultList: ResultList<VideoCommentModel> 76 let resultList: ResultList<VideoCommentModel>
78 77
@@ -88,9 +87,9 @@ async function listVideoThreads (req: express.Request, res: express.Response, ne
88 return res.json(getFormattedObjects(resultList.data, resultList.total)) 87 return res.json(getFormattedObjects(resultList.data, resultList.total))
89} 88}
90 89
91async function listVideoThreadComments (req: express.Request, res: express.Response, next: express.NextFunction) { 90async function listVideoThreadComments (req: express.Request, res: express.Response) {
92 const video = res.locals.video as VideoModel 91 const video = res.locals.video
93 const user: UserModel = res.locals.oauth ? res.locals.oauth.token.User : undefined 92 const user = res.locals.oauth ? res.locals.oauth.token.User : undefined
94 93
95 let resultList: ResultList<VideoCommentModel> 94 let resultList: ResultList<VideoCommentModel>
96 95
@@ -110,7 +109,7 @@ async function addVideoCommentThread (req: express.Request, res: express.Respons
110 const videoCommentInfo: VideoCommentCreate = req.body 109 const videoCommentInfo: VideoCommentCreate = req.body
111 110
112 const comment = await sequelizeTypescript.transaction(async t => { 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 return createVideoComment({ 114 return createVideoComment({
116 text: videoCommentInfo.text, 115 text: videoCommentInfo.text,
@@ -132,7 +131,7 @@ async function addVideoCommentReply (req: express.Request, res: express.Response
132 const videoCommentInfo: VideoCommentCreate = req.body 131 const videoCommentInfo: VideoCommentCreate = req.body
133 132
134 const comment = await sequelizeTypescript.transaction(async t => { 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 return createVideoComment({ 136 return createVideoComment({
138 text: videoCommentInfo.text, 137 text: videoCommentInfo.text,
@@ -149,7 +148,7 @@ async function addVideoCommentReply (req: express.Request, res: express.Response
149} 148}
150 149
151async function removeVideoComment (req: express.Request, res: express.Response) { 150async function removeVideoComment (req: express.Request, res: express.Response) {
152 const videoCommentInstance: VideoCommentModel = res.locals.videoComment 151 const videoCommentInstance = res.locals.videoComment
153 152
154 await sequelizeTypescript.transaction(async t => { 153 await sequelizeTypescript.transaction(async t => {
155 await videoCommentInstance.destroy({ transaction: t }) 154 await videoCommentInstance.destroy({ transaction: t })
diff --git a/server/controllers/api/videos/import.ts b/server/controllers/api/videos/import.ts
index 626c81eca..cbd2e8514 100644
--- a/server/controllers/api/videos/import.ts
+++ b/server/controllers/api/videos/import.ts
@@ -97,7 +97,7 @@ async function addTorrentImport (req: express.Request, res: express.Response, to
97 state: VideoImportState.PENDING, 97 state: VideoImportState.PENDING,
98 userId: user.id 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 // Create job to import the video 102 // Create job to import the video
103 const payload = { 103 const payload = {
@@ -139,7 +139,7 @@ async function addYoutubeDLImport (req: express.Request, res: express.Response)
139 state: VideoImportState.PENDING, 139 state: VideoImportState.PENDING,
140 userId: user.id 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 // Create job to import the video 144 // Create job to import the video
145 const payload = { 145 const payload = {
diff --git a/server/controllers/api/videos/index.ts b/server/controllers/api/videos/index.ts
index 27f67895e..db4f4c96f 100644
--- a/server/controllers/api/videos/index.ts
+++ b/server/controllers/api/videos/index.ts
@@ -295,7 +295,7 @@ async function addVideo (req: express.Request, res: express.Response) {
295} 295}
296 296
297async function updateVideo (req: express.Request, res: express.Response) { 297async function updateVideo (req: express.Request, res: express.Response) {
298 const videoInstance: VideoModel = res.locals.video 298 const videoInstance = res.locals.video
299 const videoFieldsSave = videoInstance.toJSON() 299 const videoFieldsSave = videoInstance.toJSON()
300 const oldVideoAuditView = new VideoAuditView(videoInstance.toFormattedDetailsJSON()) 300 const oldVideoAuditView = new VideoAuditView(videoInstance.toFormattedDetailsJSON())
301 const videoInfoToUpdate: VideoUpdate = req.body 301 const videoInfoToUpdate: VideoUpdate = req.body
@@ -407,7 +407,7 @@ async function updateVideo (req: express.Request, res: express.Response) {
407async function getVideo (req: express.Request, res: express.Response) { 407async function getVideo (req: express.Request, res: express.Response) {
408 // We need more attributes 408 // We need more attributes
409 const userId: number = res.locals.oauth ? res.locals.oauth.token.User.id : null 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 if (video.isOutdated()) { 412 if (video.isOutdated()) {
413 JobQueue.Instance.createJob({ type: 'activitypub-refresher', payload: { type: 'video', url: video.url } }) 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
474async function removeVideo (req: express.Request, res: express.Response) { 474async function removeVideo (req: express.Request, res: express.Response) {
475 const videoInstance: VideoModel = res.locals.video 475 const videoInstance = res.locals.video
476 476
477 await sequelizeTypescript.transaction(async t => { 477 await sequelizeTypescript.transaction(async t => {
478 await videoInstance.destroy({ transaction: t }) 478 await videoInstance.destroy({ transaction: t })
diff --git a/server/controllers/api/videos/ownership.ts b/server/controllers/api/videos/ownership.ts
index 5ea7d7c6a..fc73856c9 100644
--- a/server/controllers/api/videos/ownership.ts
+++ b/server/controllers/api/videos/ownership.ts
@@ -11,8 +11,6 @@ import {
11 videosChangeOwnershipValidator, 11 videosChangeOwnershipValidator,
12 videosTerminateChangeOwnershipValidator 12 videosTerminateChangeOwnershipValidator
13} from '../../../middlewares' 13} from '../../../middlewares'
14import { AccountModel } from '../../../models/account/account'
15import { VideoModel } from '../../../models/video/video'
16import { VideoChangeOwnershipModel } from '../../../models/video/video-change-ownership' 14import { VideoChangeOwnershipModel } from '../../../models/video/video-change-ownership'
17import { VideoChangeOwnershipStatus, VideoPrivacy, VideoState } from '../../../../shared/models/videos' 15import { VideoChangeOwnershipStatus, VideoPrivacy, VideoState } from '../../../../shared/models/videos'
18import { VideoChannelModel } from '../../../models/video/video-channel' 16import { VideoChannelModel } from '../../../models/video/video-channel'
@@ -58,9 +56,9 @@ export {
58// --------------------------------------------------------------------------- 56// ---------------------------------------------------------------------------
59 57
60async function giveVideoOwnership (req: express.Request, res: express.Response) { 58async function giveVideoOwnership (req: express.Request, res: express.Response) {
61 const videoInstance = res.locals.video as VideoModel 59 const videoInstance = res.locals.video
62 const initiatorAccountId = (res.locals.oauth.token.User as UserModel).Account.id 60 const initiatorAccountId = res.locals.oauth.token.User.Account.id
63 const nextOwner = res.locals.nextOwner as AccountModel 61 const nextOwner = res.locals.nextOwner
64 62
65 await sequelizeTypescript.transaction(t => { 63 await sequelizeTypescript.transaction(t => {
66 return VideoChangeOwnershipModel.findOrCreate({ 64 return VideoChangeOwnershipModel.findOrCreate({
@@ -85,7 +83,7 @@ async function giveVideoOwnership (req: express.Request, res: express.Response)
85} 83}
86 84
87async function listVideoOwnership (req: express.Request, res: express.Response) { 85async 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 const resultList = await VideoChangeOwnershipModel.listForApi( 88 const resultList = await VideoChangeOwnershipModel.listForApi(
91 currentAccountId, 89 currentAccountId,
@@ -99,9 +97,9 @@ async function listVideoOwnership (req: express.Request, res: express.Response)
99 97
100async function acceptOwnership (req: express.Request, res: express.Response) { 98async function acceptOwnership (req: express.Request, res: express.Response) {
101 return sequelizeTypescript.transaction(async t => { 99 return sequelizeTypescript.transaction(async t => {
102 const videoChangeOwnership = res.locals.videoChangeOwnership as VideoChangeOwnershipModel 100 const videoChangeOwnership = res.locals.videoChangeOwnership
103 const targetVideo = videoChangeOwnership.Video 101 const targetVideo = videoChangeOwnership.Video
104 const channel = res.locals.videoChannel as VideoChannelModel 102 const channel = res.locals.videoChannel
105 103
106 const oldVideoChannel = await VideoChannelModel.loadByIdAndPopulateAccount(targetVideo.channelId) 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
124async function refuseOwnership (req: express.Request, res: express.Response) { 122async function refuseOwnership (req: express.Request, res: express.Response) {
125 return sequelizeTypescript.transaction(async t => { 123 return sequelizeTypescript.transaction(async t => {
126 const videoChangeOwnership = res.locals.videoChangeOwnership as VideoChangeOwnershipModel 124 const videoChangeOwnership = res.locals.videoChangeOwnership
127 125
128 videoChangeOwnership.set('status', VideoChangeOwnershipStatus.REFUSED) 126 videoChangeOwnership.set('status', VideoChangeOwnershipStatus.REFUSED)
129 await videoChangeOwnership.save({ transaction: t }) 127 await videoChangeOwnership.save({ transaction: t })
diff --git a/server/controllers/api/videos/rate.ts b/server/controllers/api/videos/rate.ts
index 53952a0a2..914c596c3 100644
--- a/server/controllers/api/videos/rate.ts
+++ b/server/controllers/api/videos/rate.ts
@@ -6,7 +6,6 @@ import { getRateUrl, sendVideoRateChange } from '../../../lib/activitypub'
6import { asyncMiddleware, asyncRetryTransactionMiddleware, authenticate, videoUpdateRateValidator } from '../../../middlewares' 6import { asyncMiddleware, asyncRetryTransactionMiddleware, authenticate, videoUpdateRateValidator } from '../../../middlewares'
7import { AccountModel } from '../../../models/account/account' 7import { AccountModel } from '../../../models/account/account'
8import { AccountVideoRateModel } from '../../../models/account/account-video-rate' 8import { AccountVideoRateModel } from '../../../models/account/account-video-rate'
9import { VideoModel } from '../../../models/video/video'
10 9
11const rateVideoRouter = express.Router() 10const rateVideoRouter = express.Router()
12 11
@@ -27,8 +26,8 @@ export {
27async function rateVideo (req: express.Request, res: express.Response) { 26async function rateVideo (req: express.Request, res: express.Response) {
28 const body: UserVideoRateUpdate = req.body 27 const body: UserVideoRateUpdate = req.body
29 const rateType = body.rating 28 const rateType = body.rating
30 const videoInstance: VideoModel = res.locals.video 29 const videoInstance = res.locals.video
31 const userAccount: AccountModel = res.locals.oauth.token.User.Account 30 const userAccount = res.locals.oauth.token.User.Account
32 31
33 await sequelizeTypescript.transaction(async t => { 32 await sequelizeTypescript.transaction(async t => {
34 const sequelizeOptions = { transaction: t } 33 const sequelizeOptions = { transaction: t }
diff --git a/server/controllers/api/videos/watching.ts b/server/controllers/api/videos/watching.ts
index e8876b47a..6bc60e045 100644
--- a/server/controllers/api/videos/watching.ts
+++ b/server/controllers/api/videos/watching.ts
@@ -21,7 +21,7 @@ export {
21// --------------------------------------------------------------------------- 21// ---------------------------------------------------------------------------
22 22
23async function userWatchVideo (req: express.Request, res: express.Response) { 23async 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 const body: UserWatchingVideo = req.body 26 const body: UserWatchingVideo = req.body
27 const { id: videoId } = res.locals.video as { id: number } 27 const { id: videoId } = res.locals.video as { id: number }
diff --git a/server/controllers/feeds.ts b/server/controllers/feeds.ts
index 960085af1..cd46b6e0f 100644
--- a/server/controllers/feeds.ts
+++ b/server/controllers/feeds.ts
@@ -11,9 +11,7 @@ import {
11} from '../middlewares' 11} from '../middlewares'
12import { VideoModel } from '../models/video/video' 12import { VideoModel } from '../models/video/video'
13import * as Feed from 'pfeed' 13import * as Feed from 'pfeed'
14import { AccountModel } from '../models/account/account'
15import { cacheRoute } from '../middlewares/cache' 14import { cacheRoute } from '../middlewares/cache'
16import { VideoChannelModel } from '../models/video/video-channel'
17import { VideoCommentModel } from '../models/video/video-comment' 15import { VideoCommentModel } from '../models/video/video-comment'
18import { buildNSFWFilter } from '../helpers/express-utils' 16import { buildNSFWFilter } from '../helpers/express-utils'
19 17
@@ -42,10 +40,10 @@ export {
42 40
43// --------------------------------------------------------------------------- 41// ---------------------------------------------------------------------------
44 42
45async function generateVideoCommentsFeed (req: express.Request, res: express.Response, next: express.NextFunction) { 43async function generateVideoCommentsFeed (req: express.Request, res: express.Response) {
46 const start = 0 44 const start = 0
47 45
48 const video = res.locals.video as VideoModel 46 const video = res.locals.video
49 const videoId: number = video ? video.id : undefined 47 const videoId: number = video ? video.id : undefined
50 48
51 const comments = await VideoCommentModel.listForFeed(start, FEEDS.COUNT, videoId) 49 const comments = await VideoCommentModel.listForFeed(start, FEEDS.COUNT, videoId)
@@ -77,11 +75,11 @@ async function generateVideoCommentsFeed (req: express.Request, res: express.Res
77 return sendFeed(feed, req, res) 75 return sendFeed(feed, req, res)
78} 76}
79 77
80async function generateVideoFeed (req: express.Request, res: express.Response, next: express.NextFunction) { 78async function generateVideoFeed (req: express.Request, res: express.Response) {
81 const start = 0 79 const start = 0
82 80
83 const account: AccountModel = res.locals.account 81 const account = res.locals.account
84 const videoChannel: VideoChannelModel = res.locals.videoChannel 82 const videoChannel = res.locals.videoChannel
85 const nsfw = buildNSFWFilter(res, req.query.nsfw) 83 const nsfw = buildNSFWFilter(res, req.query.nsfw)
86 84
87 let name: string 85 let name: string
diff --git a/server/controllers/services.ts b/server/controllers/services.ts
index 680c3c37f..cf7a513af 100644
--- a/server/controllers/services.ts
+++ b/server/controllers/services.ts
@@ -23,8 +23,8 @@ export {
23 23
24// --------------------------------------------------------------------------- 24// ---------------------------------------------------------------------------
25 25
26function generateOEmbed (req: express.Request, res: express.Response, next: express.NextFunction) { 26function generateOEmbed (req: express.Request, res: express.Response) {
27 const video = res.locals.video as VideoModel 27 const video = res.locals.video
28 const webserverUrl = CONFIG.WEBSERVER.URL 28 const webserverUrl = CONFIG.WEBSERVER.URL
29 const maxHeight = parseInt(req.query.maxheight, 10) 29 const maxHeight = parseInt(req.query.maxheight, 10)
30 const maxWidth = parseInt(req.query.maxwidth, 10) 30 const maxWidth = parseInt(req.query.maxwidth, 10)
diff --git a/server/controllers/static.ts b/server/controllers/static.ts
index 639445b74..7b14320e4 100644
--- a/server/controllers/static.ts
+++ b/server/controllers/static.ts
@@ -245,7 +245,7 @@ async function downloadVideoFile (req: express.Request, res: express.Response, n
245 245
246function getVideoAndFile (req: express.Request, res: express.Response) { 246function getVideoAndFile (req: express.Request, res: express.Response) {
247 const resolution = parseInt(req.params.resolution, 10) 247 const resolution = parseInt(req.params.resolution, 10)
248 const video: VideoModel = res.locals.video 248 const video = res.locals.video
249 249
250 const videoFile = video.VideoFiles.find(f => f.resolution === resolution) 250 const videoFile = video.VideoFiles.find(f => f.resolution === resolution)
251 251
diff --git a/server/controllers/webfinger.ts b/server/controllers/webfinger.ts
index ed781c21b..f2ba3c826 100644
--- a/server/controllers/webfinger.ts
+++ b/server/controllers/webfinger.ts
@@ -1,7 +1,6 @@
1import * as express from 'express' 1import * as express from 'express'
2import { asyncMiddleware } from '../middlewares' 2import { asyncMiddleware } from '../middlewares'
3import { webfingerValidator } from '../middlewares/validators' 3import { webfingerValidator } from '../middlewares/validators'
4import { ActorModel } from '../models/activitypub/actor'
5 4
6const webfingerRouter = express.Router() 5const webfingerRouter = express.Router()
7 6
@@ -18,8 +17,8 @@ export {
18 17
19// --------------------------------------------------------------------------- 18// ---------------------------------------------------------------------------
20 19
21function webfingerController (req: express.Request, res: express.Response, next: express.NextFunction) { 20function webfingerController (req: express.Request, res: express.Response) {
22 const actor = res.locals.actor as ActorModel 21 const actor = res.locals.actor
23 22
24 const json = { 23 const json = {
25 subject: req.query.resource, 24 subject: req.query.resource,