aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/controllers
diff options
context:
space:
mode:
Diffstat (limited to 'server/controllers')
-rw-r--r--server/controllers/api/videos/index.ts19
1 files changed, 10 insertions, 9 deletions
diff --git a/server/controllers/api/videos/index.ts b/server/controllers/api/videos/index.ts
index 94ed08fed..33521a8c1 100644
--- a/server/controllers/api/videos/index.ts
+++ b/server/controllers/api/videos/index.ts
@@ -264,7 +264,6 @@ async function addVideo (req: express.Request, res: express.Response) {
264 } 264 }
265 265
266 await federateVideoIfNeeded(video, true, t) 266 await federateVideoIfNeeded(video, true, t)
267 Notifier.Instance.notifyOnNewVideo(video)
268 267
269 auditLogger.create(getAuditIdFromRes(res), new VideoAuditView(videoCreated.toFormattedDetailsJSON())) 268 auditLogger.create(getAuditIdFromRes(res), new VideoAuditView(videoCreated.toFormattedDetailsJSON()))
270 logger.info('Video with name %s and uuid %s created.', videoInfo.name, videoCreated.uuid) 269 logger.info('Video with name %s and uuid %s created.', videoInfo.name, videoCreated.uuid)
@@ -272,6 +271,8 @@ async function addVideo (req: express.Request, res: express.Response) {
272 return videoCreated 271 return videoCreated
273 }) 272 })
274 273
274 Notifier.Instance.notifyOnNewVideo(videoCreated)
275
275 if (video.state === VideoState.TO_TRANSCODE) { 276 if (video.state === VideoState.TO_TRANSCODE) {
276 // Put uuid because we don't have id auto incremented for now 277 // Put uuid because we don't have id auto incremented for now
277 const dataInput = { 278 const dataInput = {
@@ -311,10 +312,8 @@ async function updateVideo (req: express.Request, res: express.Response) {
311 } 312 }
312 313
313 try { 314 try {
314 await sequelizeTypescript.transaction(async t => { 315 const videoInstanceUpdated = await sequelizeTypescript.transaction(async t => {
315 const sequelizeOptions = { 316 const sequelizeOptions = { transaction: t }
316 transaction: t
317 }
318 const oldVideoChannel = videoInstance.VideoChannel 317 const oldVideoChannel = videoInstance.VideoChannel
319 318
320 if (videoInfoToUpdate.name !== undefined) videoInstance.set('name', videoInfoToUpdate.name) 319 if (videoInfoToUpdate.name !== undefined) videoInstance.set('name', videoInfoToUpdate.name)
@@ -367,17 +366,19 @@ async function updateVideo (req: express.Request, res: express.Response) {
367 const isNewVideo = wasPrivateVideo && videoInstanceUpdated.privacy !== VideoPrivacy.PRIVATE 366 const isNewVideo = wasPrivateVideo && videoInstanceUpdated.privacy !== VideoPrivacy.PRIVATE
368 await federateVideoIfNeeded(videoInstanceUpdated, isNewVideo, t) 367 await federateVideoIfNeeded(videoInstanceUpdated, isNewVideo, t)
369 368
370 if (wasUnlistedVideo || wasPrivateVideo) {
371 Notifier.Instance.notifyOnNewVideo(videoInstanceUpdated)
372 }
373
374 auditLogger.update( 369 auditLogger.update(
375 getAuditIdFromRes(res), 370 getAuditIdFromRes(res),
376 new VideoAuditView(videoInstanceUpdated.toFormattedDetailsJSON()), 371 new VideoAuditView(videoInstanceUpdated.toFormattedDetailsJSON()),
377 oldVideoAuditView 372 oldVideoAuditView
378 ) 373 )
379 logger.info('Video with name %s and uuid %s updated.', videoInstance.name, videoInstance.uuid) 374 logger.info('Video with name %s and uuid %s updated.', videoInstance.name, videoInstance.uuid)
375
376 return videoInstanceUpdated
380 }) 377 })
378
379 if (wasUnlistedVideo || wasPrivateVideo) {
380 Notifier.Instance.notifyOnNewVideo(videoInstanceUpdated)
381 }
381 } catch (err) { 382 } catch (err) {
382 // Force fields we want to update 383 // Force fields we want to update
383 // If the transaction is retried, sequelize will think the object has not changed 384 // If the transaction is retried, sequelize will think the object has not changed