aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/lib/activitypub/videos.ts
diff options
context:
space:
mode:
Diffstat (limited to 'server/lib/activitypub/videos.ts')
-rw-r--r--server/lib/activitypub/videos.ts28
1 files changed, 21 insertions, 7 deletions
diff --git a/server/lib/activitypub/videos.ts b/server/lib/activitypub/videos.ts
index dade6b55f..67b433165 100644
--- a/server/lib/activitypub/videos.ts
+++ b/server/lib/activitypub/videos.ts
@@ -224,11 +224,11 @@ async function getOrCreateVideoAndAccountAndChannel (options: {
224 if (!fetchedVideo) throw new Error('Cannot fetch remote video with url: ' + videoUrl) 224 if (!fetchedVideo) throw new Error('Cannot fetch remote video with url: ' + videoUrl)
225 225
226 const channelActor = await getOrCreateVideoChannelFromVideoObject(fetchedVideo) 226 const channelActor = await getOrCreateVideoChannelFromVideoObject(fetchedVideo)
227 const video = await retryTransactionWrapper(createVideo, fetchedVideo, channelActor, syncParam.thumbnail) 227 const { autoBlacklisted, videoCreated } = await retryTransactionWrapper(createVideo, fetchedVideo, channelActor, syncParam.thumbnail)
228 228
229 await syncVideoExternalAttributes(video, fetchedVideo, syncParam) 229 await syncVideoExternalAttributes(videoCreated, fetchedVideo, syncParam)
230 230
231 return { video, created: true } 231 return { video: videoCreated, created: true, autoBlacklisted }
232} 232}
233 233
234async function updateVideoFromAP (options: { 234async function updateVideoFromAP (options: {
@@ -354,7 +354,13 @@ async function updateVideoFromAP (options: {
354 } 354 }
355 }) 355 })
356 356
357 const autoBlacklisted = await autoBlacklistVideoIfNeeded(video, undefined, undefined) 357 const autoBlacklisted = await autoBlacklistVideoIfNeeded({
358 video,
359 user: undefined,
360 isRemote: true,
361 isNew: false,
362 transaction: undefined
363 })
358 364
359 if (autoBlacklisted) Notifier.Instance.notifyOnVideoAutoBlacklist(video) 365 if (autoBlacklisted) Notifier.Instance.notifyOnVideoAutoBlacklist(video)
360 else if (!wasPrivateVideo || wasUnlistedVideo) Notifier.Instance.notifyOnNewVideo(video) // Notify our users? 366 else if (!wasPrivateVideo || wasUnlistedVideo) Notifier.Instance.notifyOnNewVideo(video) // Notify our users?
@@ -467,7 +473,7 @@ async function createVideo (videoObject: VideoTorrentObject, channelActor: Actor
467 thumbnailModel = await promiseThumbnail 473 thumbnailModel = await promiseThumbnail
468 } 474 }
469 475
470 const videoCreated: VideoModel = await sequelizeTypescript.transaction(async t => { 476 const { autoBlacklisted, videoCreated } = await sequelizeTypescript.transaction(async t => {
471 const sequelizeOptions = { transaction: t } 477 const sequelizeOptions = { transaction: t }
472 478
473 const videoCreated = await video.save(sequelizeOptions) 479 const videoCreated = await video.save(sequelizeOptions)
@@ -506,9 +512,17 @@ async function createVideo (videoObject: VideoTorrentObject, channelActor: Actor
506 }) 512 })
507 await Promise.all(videoCaptionsPromises) 513 await Promise.all(videoCaptionsPromises)
508 514
515 const autoBlacklisted = await autoBlacklistVideoIfNeeded({
516 video,
517 user: undefined,
518 isRemote: true,
519 isNew: true,
520 transaction: t
521 })
522
509 logger.info('Remote video with uuid %s inserted.', videoObject.uuid) 523 logger.info('Remote video with uuid %s inserted.', videoObject.uuid)
510 524
511 return videoCreated 525 return { autoBlacklisted, videoCreated }
512 }) 526 })
513 527
514 if (waitThumbnail === false) { 528 if (waitThumbnail === false) {
@@ -519,7 +533,7 @@ async function createVideo (videoObject: VideoTorrentObject, channelActor: Actor
519 }) 533 })
520 } 534 }
521 535
522 return videoCreated 536 return { autoBlacklisted, videoCreated }
523} 537}
524 538
525async function videoActivityObjectToDBAttributes ( 539async function videoActivityObjectToDBAttributes (