diff options
author | Chocobozzz <me@florianbigard.com> | 2019-03-19 10:35:15 +0100 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2019-03-19 10:35:15 +0100 |
commit | dae86118ed5d4026d04acb9d0e36829b9ad8eb4e (patch) | |
tree | a5bf9c4487240bf75a9b328cad459a0587f90dea /server/controllers/api/videos/ownership.ts | |
parent | e65c0c5b1fab9c3d93f51721b2458cf5cf471f20 (diff) | |
download | PeerTube-dae86118ed5d4026d04acb9d0e36829b9ad8eb4e.tar.gz PeerTube-dae86118ed5d4026d04acb9d0e36829b9ad8eb4e.tar.zst PeerTube-dae86118ed5d4026d04acb9d0e36829b9ad8eb4e.zip |
Cleanup express locals typings
Diffstat (limited to 'server/controllers/api/videos/ownership.ts')
-rw-r--r-- | server/controllers/api/videos/ownership.ts | 16 |
1 files changed, 7 insertions, 9 deletions
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' |
14 | import { AccountModel } from '../../../models/account/account' | ||
15 | import { VideoModel } from '../../../models/video/video' | ||
16 | import { VideoChangeOwnershipModel } from '../../../models/video/video-change-ownership' | 14 | import { VideoChangeOwnershipModel } from '../../../models/video/video-change-ownership' |
17 | import { VideoChangeOwnershipStatus, VideoPrivacy, VideoState } from '../../../../shared/models/videos' | 15 | import { VideoChangeOwnershipStatus, VideoPrivacy, VideoState } from '../../../../shared/models/videos' |
18 | import { VideoChannelModel } from '../../../models/video/video-channel' | 16 | import { VideoChannelModel } from '../../../models/video/video-channel' |
@@ -58,9 +56,9 @@ export { | |||
58 | // --------------------------------------------------------------------------- | 56 | // --------------------------------------------------------------------------- |
59 | 57 | ||
60 | async function giveVideoOwnership (req: express.Request, res: express.Response) { | 58 | async 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 | ||
87 | async function listVideoOwnership (req: express.Request, res: express.Response) { | 85 | async function listVideoOwnership (req: express.Request, res: express.Response) { |
88 | const currentAccountId = (res.locals.oauth.token.User as UserModel).Account.id | 86 | const currentAccountId = res.locals.oauth.token.User.Account.id |
89 | 87 | ||
90 | 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 | ||
100 | async function acceptOwnership (req: express.Request, res: express.Response) { | 98 | async 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 | ||
124 | async function refuseOwnership (req: express.Request, res: express.Response) { | 122 | async 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 }) |