diff options
Diffstat (limited to 'server/lib/activitypub')
-rw-r--r-- | server/lib/activitypub/process/process-create.ts | 4 | ||||
-rw-r--r-- | server/lib/activitypub/videos.ts | 28 |
2 files changed, 23 insertions, 9 deletions
diff --git a/server/lib/activitypub/process/process-create.ts b/server/lib/activitypub/process/process-create.ts index daf846513..b9f584aa5 100644 --- a/server/lib/activitypub/process/process-create.ts +++ b/server/lib/activitypub/process/process-create.ts | |||
@@ -48,9 +48,9 @@ export { | |||
48 | async function processCreateVideo (activity: ActivityCreate) { | 48 | async function processCreateVideo (activity: ActivityCreate) { |
49 | const videoToCreateData = activity.object as VideoTorrentObject | 49 | const videoToCreateData = activity.object as VideoTorrentObject |
50 | 50 | ||
51 | const { video, created } = await getOrCreateVideoAndAccountAndChannel({ videoObject: videoToCreateData }) | 51 | const { video, created, autoBlacklisted } = await getOrCreateVideoAndAccountAndChannel({ videoObject: videoToCreateData }) |
52 | 52 | ||
53 | if (created) Notifier.Instance.notifyOnNewVideo(video) | 53 | if (created && !autoBlacklisted) Notifier.Instance.notifyOnNewVideo(video) |
54 | 54 | ||
55 | return video | 55 | return video |
56 | } | 56 | } |
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 | ||
234 | async function updateVideoFromAP (options: { | 234 | async 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 | ||
525 | async function videoActivityObjectToDBAttributes ( | 539 | async function videoActivityObjectToDBAttributes ( |