aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/controllers/api/videos
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2019-03-19 10:35:15 +0100
committerChocobozzz <me@florianbigard.com>2019-03-19 10:35:15 +0100
commitdae86118ed5d4026d04acb9d0e36829b9ad8eb4e (patch)
treea5bf9c4487240bf75a9b328cad459a0587f90dea /server/controllers/api/videos
parente65c0c5b1fab9c3d93f51721b2458cf5cf471f20 (diff)
downloadPeerTube-dae86118ed5d4026d04acb9d0e36829b9ad8eb4e.tar.gz
PeerTube-dae86118ed5d4026d04acb9d0e36829b9ad8eb4e.tar.zst
PeerTube-dae86118ed5d4026d04acb9d0e36829b9ad8eb4e.zip
Cleanup express locals typings
Diffstat (limited to 'server/controllers/api/videos')
-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
9 files changed, 36 insertions, 44 deletions
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 }