aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/controllers/api/videos/index.ts
diff options
context:
space:
mode:
Diffstat (limited to 'server/controllers/api/videos/index.ts')
-rw-r--r--server/controllers/api/videos/index.ts19
1 files changed, 7 insertions, 12 deletions
diff --git a/server/controllers/api/videos/index.ts b/server/controllers/api/videos/index.ts
index 6a79a16c7..973bf1123 100644
--- a/server/controllers/api/videos/index.ts
+++ b/server/controllers/api/videos/index.ts
@@ -235,7 +235,7 @@ async function addVideo (req: express.Request, res: express.Response) {
235 // Create the torrent file 235 // Create the torrent file
236 await video.createTorrentAndSetInfoHash(videoFile) 236 await video.createTorrentAndSetInfoHash(videoFile)
237 237
238 const { videoCreated, videoWasAutoBlacklisted } = await sequelizeTypescript.transaction(async t => { 238 const { videoCreated } = await sequelizeTypescript.transaction(async t => {
239 const sequelizeOptions = { transaction: t } 239 const sequelizeOptions = { transaction: t }
240 240
241 const videoCreated = await video.save(sequelizeOptions) 241 const videoCreated = await video.save(sequelizeOptions)
@@ -268,23 +268,22 @@ async function addVideo (req: express.Request, res: express.Response) {
268 }, { transaction: t }) 268 }, { transaction: t })
269 } 269 }
270 270
271 const videoWasAutoBlacklisted = await autoBlacklistVideoIfNeeded({ 271 await autoBlacklistVideoIfNeeded({
272 video, 272 video,
273 user: res.locals.oauth.token.User, 273 user: res.locals.oauth.token.User,
274 isRemote: false, 274 isRemote: false,
275 isNew: true, 275 isNew: true,
276 transaction: t 276 transaction: t
277 }) 277 })
278 if (!videoWasAutoBlacklisted) await federateVideoIfNeeded(video, true, t) 278 await federateVideoIfNeeded(video, true, t)
279 279
280 auditLogger.create(getAuditIdFromRes(res), new VideoAuditView(videoCreated.toFormattedDetailsJSON())) 280 auditLogger.create(getAuditIdFromRes(res), new VideoAuditView(videoCreated.toFormattedDetailsJSON()))
281 logger.info('Video with name %s and uuid %s created.', videoInfo.name, videoCreated.uuid) 281 logger.info('Video with name %s and uuid %s created.', videoInfo.name, videoCreated.uuid)
282 282
283 return { videoCreated, videoWasAutoBlacklisted } 283 return { videoCreated }
284 }) 284 })
285 285
286 if (videoWasAutoBlacklisted) Notifier.Instance.notifyOnVideoAutoBlacklist(videoCreated) 286 Notifier.Instance.notifyOnNewVideoIfNeeded(videoCreated)
287 else Notifier.Instance.notifyOnNewVideo(videoCreated)
288 287
289 if (video.state === VideoState.TO_TRANSCODE) { 288 if (video.state === VideoState.TO_TRANSCODE) {
290 // Put uuid because we don't have id auto incremented for now 289 // Put uuid because we don't have id auto incremented for now
@@ -413,11 +412,7 @@ async function updateVideo (req: express.Request, res: express.Response) {
413 }) 412 })
414 413
415 const isNewVideo = wasPrivateVideo && videoInstanceUpdated.privacy !== VideoPrivacy.PRIVATE 414 const isNewVideo = wasPrivateVideo && videoInstanceUpdated.privacy !== VideoPrivacy.PRIVATE
416 415 await federateVideoIfNeeded(videoInstanceUpdated, isNewVideo, t)
417 // Don't send update if the video was unfederated
418 if (!videoInstanceUpdated.VideoBlacklist || videoInstanceUpdated.VideoBlacklist.unfederated === false) {
419 await federateVideoIfNeeded(videoInstanceUpdated, isNewVideo, t)
420 }
421 416
422 auditLogger.update( 417 auditLogger.update(
423 getAuditIdFromRes(res), 418 getAuditIdFromRes(res),
@@ -430,7 +425,7 @@ async function updateVideo (req: express.Request, res: express.Response) {
430 }) 425 })
431 426
432 if (wasUnlistedVideo || wasPrivateVideo) { 427 if (wasUnlistedVideo || wasPrivateVideo) {
433 Notifier.Instance.notifyOnNewVideo(videoInstanceUpdated) 428 Notifier.Instance.notifyOnNewVideoIfNeeded(videoInstanceUpdated)
434 } 429 }
435 430
436 Hooks.runAction('action:api.video.updated', { video: videoInstanceUpdated }) 431 Hooks.runAction('action:api.video.updated', { video: videoInstanceUpdated })