aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/controllers/api/videos/ownership.ts
diff options
context:
space:
mode:
Diffstat (limited to 'server/controllers/api/videos/ownership.ts')
-rw-r--r--server/controllers/api/videos/ownership.ts16
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'
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 })