aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/lib/activitypub
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2019-07-23 12:04:15 +0200
committerChocobozzz <chocobozzz@cpy.re>2019-07-24 10:58:16 +0200
commit5b77537ce54832f47931ba47dc513be2a9197f92 (patch)
tree4f968168f1346faa82ac6c9663778e1cca65b02a /server/lib/activitypub
parentd8e9a42c4b048b2669ab6a61704682ce23fbcf99 (diff)
downloadPeerTube-5b77537ce54832f47931ba47dc513be2a9197f92.tar.gz
PeerTube-5b77537ce54832f47931ba47dc513be2a9197f92.tar.zst
PeerTube-5b77537ce54832f47931ba47dc513be2a9197f92.zip
Correctly notify on auto blacklist
Diffstat (limited to 'server/lib/activitypub')
-rw-r--r--server/lib/activitypub/process/process-announce.ts2
-rw-r--r--server/lib/activitypub/process/process-create.ts4
-rw-r--r--server/lib/activitypub/videos.ts13
3 files changed, 11 insertions, 8 deletions
diff --git a/server/lib/activitypub/process/process-announce.ts b/server/lib/activitypub/process/process-announce.ts
index bbf1bd3a8..1fe347506 100644
--- a/server/lib/activitypub/process/process-announce.ts
+++ b/server/lib/activitypub/process/process-announce.ts
@@ -63,5 +63,5 @@ async function processVideoShare (actorAnnouncer: ActorModel, activity: Activity
63 return undefined 63 return undefined
64 }) 64 })
65 65
66 if (videoCreated) Notifier.Instance.notifyOnNewVideo(video) 66 if (videoCreated) Notifier.Instance.notifyOnNewVideoIfNeeded(video)
67} 67}
diff --git a/server/lib/activitypub/process/process-create.ts b/server/lib/activitypub/process/process-create.ts
index b9f584aa5..1e893cdeb 100644
--- a/server/lib/activitypub/process/process-create.ts
+++ b/server/lib/activitypub/process/process-create.ts
@@ -48,9 +48,9 @@ export {
48async function processCreateVideo (activity: ActivityCreate) { 48async function processCreateVideo (activity: ActivityCreate) {
49 const videoToCreateData = activity.object as VideoTorrentObject 49 const videoToCreateData = activity.object as VideoTorrentObject
50 50
51 const { video, created, autoBlacklisted } = await getOrCreateVideoAndAccountAndChannel({ videoObject: videoToCreateData }) 51 const { video, created } = await getOrCreateVideoAndAccountAndChannel({ videoObject: videoToCreateData })
52 52
53 if (created && !autoBlacklisted) Notifier.Instance.notifyOnNewVideo(video) 53 if (created) Notifier.Instance.notifyOnNewVideoIfNeeded(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 67b433165..d7bc3d650 100644
--- a/server/lib/activitypub/videos.ts
+++ b/server/lib/activitypub/videos.ts
@@ -58,8 +58,12 @@ import { Hooks } from '../plugins/hooks'
58import { autoBlacklistVideoIfNeeded } from '../video-blacklist' 58import { autoBlacklistVideoIfNeeded } from '../video-blacklist'
59 59
60async function federateVideoIfNeeded (video: VideoModel, isNewVideo: boolean, transaction?: sequelize.Transaction) { 60async function federateVideoIfNeeded (video: VideoModel, isNewVideo: boolean, transaction?: sequelize.Transaction) {
61 // If the video is not private and is published, we federate it 61 if (
62 if (video.privacy !== VideoPrivacy.PRIVATE && video.state === VideoState.PUBLISHED) { 62 // Check this is not a blacklisted video, or unfederated blacklisted video
63 (video.isBlacklisted() === false || (isNewVideo === false && video.VideoBlacklist.unfederated === false)) &&
64 // Check the video is public/unlisted and published
65 video.privacy !== VideoPrivacy.PRIVATE && video.state === VideoState.PUBLISHED
66 ) {
63 // Fetch more attributes that we will need to serialize in AP object 67 // Fetch more attributes that we will need to serialize in AP object
64 if (isArray(video.VideoCaptions) === false) { 68 if (isArray(video.VideoCaptions) === false) {
65 video.VideoCaptions = await video.$get('VideoCaptions', { 69 video.VideoCaptions = await video.$get('VideoCaptions', {
@@ -354,7 +358,7 @@ async function updateVideoFromAP (options: {
354 } 358 }
355 }) 359 })
356 360
357 const autoBlacklisted = await autoBlacklistVideoIfNeeded({ 361 await autoBlacklistVideoIfNeeded({
358 video, 362 video,
359 user: undefined, 363 user: undefined,
360 isRemote: true, 364 isRemote: true,
@@ -362,8 +366,7 @@ async function updateVideoFromAP (options: {
362 transaction: undefined 366 transaction: undefined
363 }) 367 })
364 368
365 if (autoBlacklisted) Notifier.Instance.notifyOnVideoAutoBlacklist(video) 369 if (wasPrivateVideo || wasUnlistedVideo) Notifier.Instance.notifyOnNewVideoIfNeeded(video) // Notify our users?
366 else if (!wasPrivateVideo || wasUnlistedVideo) Notifier.Instance.notifyOnNewVideo(video) // Notify our users?
367 370
368 logger.info('Remote video with uuid %s updated', videoObject.uuid) 371 logger.info('Remote video with uuid %s updated', videoObject.uuid)
369 } catch (err) { 372 } catch (err) {