diff options
Diffstat (limited to 'server/controllers/api/videos/ownership.ts')
-rw-r--r-- | server/controllers/api/videos/ownership.ts | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/server/controllers/api/videos/ownership.ts b/server/controllers/api/videos/ownership.ts index d26ed6cfc..5ea7d7c6a 100644 --- a/server/controllers/api/videos/ownership.ts +++ b/server/controllers/api/videos/ownership.ts | |||
@@ -19,6 +19,7 @@ import { VideoChannelModel } from '../../../models/video/video-channel' | |||
19 | import { getFormattedObjects } from '../../../helpers/utils' | 19 | import { getFormattedObjects } from '../../../helpers/utils' |
20 | import { changeVideoChannelShare } from '../../../lib/activitypub' | 20 | import { changeVideoChannelShare } from '../../../lib/activitypub' |
21 | import { sendUpdateVideo } from '../../../lib/activitypub/send' | 21 | import { sendUpdateVideo } from '../../../lib/activitypub/send' |
22 | import { UserModel } from '../../../models/account/user' | ||
22 | 23 | ||
23 | const ownershipVideoRouter = express.Router() | 24 | const ownershipVideoRouter = express.Router() |
24 | 25 | ||
@@ -58,26 +59,25 @@ export { | |||
58 | 59 | ||
59 | async function giveVideoOwnership (req: express.Request, res: express.Response) { | 60 | async function giveVideoOwnership (req: express.Request, res: express.Response) { |
60 | const videoInstance = res.locals.video as VideoModel | 61 | const videoInstance = res.locals.video as VideoModel |
61 | const initiatorAccount = res.locals.oauth.token.User.Account as AccountModel | 62 | const initiatorAccountId = (res.locals.oauth.token.User as UserModel).Account.id |
62 | const nextOwner = res.locals.nextOwner as AccountModel | 63 | const nextOwner = res.locals.nextOwner as AccountModel |
63 | 64 | ||
64 | await sequelizeTypescript.transaction(t => { | 65 | await sequelizeTypescript.transaction(t => { |
65 | return VideoChangeOwnershipModel.findOrCreate({ | 66 | return VideoChangeOwnershipModel.findOrCreate({ |
66 | where: { | 67 | where: { |
67 | initiatorAccountId: initiatorAccount.id, | 68 | initiatorAccountId, |
68 | nextOwnerAccountId: nextOwner.id, | 69 | nextOwnerAccountId: nextOwner.id, |
69 | videoId: videoInstance.id, | 70 | videoId: videoInstance.id, |
70 | status: VideoChangeOwnershipStatus.WAITING | 71 | status: VideoChangeOwnershipStatus.WAITING |
71 | }, | 72 | }, |
72 | defaults: { | 73 | defaults: { |
73 | initiatorAccountId: initiatorAccount.id, | 74 | initiatorAccountId, |
74 | nextOwnerAccountId: nextOwner.id, | 75 | nextOwnerAccountId: nextOwner.id, |
75 | videoId: videoInstance.id, | 76 | videoId: videoInstance.id, |
76 | status: VideoChangeOwnershipStatus.WAITING | 77 | status: VideoChangeOwnershipStatus.WAITING |
77 | }, | 78 | }, |
78 | transaction: t | 79 | transaction: t |
79 | }) | 80 | }) |
80 | |||
81 | }) | 81 | }) |
82 | 82 | ||
83 | logger.info('Ownership change for video %s created.', videoInstance.name) | 83 | logger.info('Ownership change for video %s created.', videoInstance.name) |
@@ -85,9 +85,10 @@ async function giveVideoOwnership (req: express.Request, res: express.Response) | |||
85 | } | 85 | } |
86 | 86 | ||
87 | async function listVideoOwnership (req: express.Request, res: express.Response) { | 87 | async function listVideoOwnership (req: express.Request, res: express.Response) { |
88 | const currentAccount = res.locals.oauth.token.User.Account as AccountModel | 88 | const currentAccountId = (res.locals.oauth.token.User as UserModel).Account.id |
89 | |||
89 | const resultList = await VideoChangeOwnershipModel.listForApi( | 90 | const resultList = await VideoChangeOwnershipModel.listForApi( |
90 | currentAccount.id, | 91 | currentAccountId, |
91 | req.query.start || 0, | 92 | req.query.start || 0, |
92 | req.query.count || 10, | 93 | req.query.count || 10, |
93 | req.query.sort || 'createdAt' | 94 | req.query.sort || 'createdAt' |