aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/lib/activitypub/videos.ts
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/videos.ts
parentd8e9a42c4b048b2669ab6a61704682ce23fbcf99 (diff)
downloadPeerTube-5b77537ce54832f47931ba47dc513be2a9197f92.tar.gz
PeerTube-5b77537ce54832f47931ba47dc513be2a9197f92.tar.zst
PeerTube-5b77537ce54832f47931ba47dc513be2a9197f92.zip
Correctly notify on auto blacklist
Diffstat (limited to 'server/lib/activitypub/videos.ts')
-rw-r--r--server/lib/activitypub/videos.ts13
1 files changed, 8 insertions, 5 deletions
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) {