Skip to content

ActivityPub-federated video streaming platform using P2P directly in your web browser

Prevent federation error in logs

Chocobozzz13674f98ac96
diff --git a/server/core/lib/activitypub/send/send-download.ts b/server/core/lib/activitypub/send/send-download.ts
index 0c123f3ddb..fc24f84b41 100644
--- a/server/core/lib/activitypub/send/send-download.ts
+++ b/server/core/lib/activitypub/send/send-download.ts
@@ -1,9 +1,11 @@
import { ActivityAudience, ActivityDownload } from '@peertube/peertube-models'
+import { VideoModel } from '@server/models/video/video.js'
import { MActorAudience, MActorLight, MVideoImmutable, MVideoUrl } from '@server/types/models/index.js'
import { Transaction } from 'sequelize'
import { logger } from '../../../helpers/logger.js'
import { audiencify, getPublicAudience } from '../audience.js'
import { getDownloadsActivityPubUrl } from '../url.js'
+import { canVideoBeFederated } from '../videos/index.js'
import { sendVideoRelatedActivity } from './shared/send-utils.js'
async function sendDownload (options: {
@@ -11,7 +13,10 @@ async function sendDownload (options: {
video: MVideoImmutable
transaction?: Transaction
}) {
- const { byActor, video, transaction } = options
+ const { byActor, transaction } = options
+
+ const video = await VideoModel.loadWithRights(options.video.id, transaction)
+ if (!canVideoBeFederated(video)) return undefined
logger.info('Creating job to send downloads of %s.', video.url)
diff --git a/server/core/lib/activitypub/send/send-view.ts b/server/core/lib/activitypub/send/send-view.ts
index 30ec19662a..1257820141 100644
--- a/server/core/lib/activitypub/send/send-view.ts
+++ b/server/core/lib/activitypub/send/send-view.ts
@@ -1,11 +1,13 @@
import { ActivityAudience, ActivityView } from '@peertube/peertube-models'
import { VideoStatsManager } from '@server/lib/stats/video-stats-manager.js'
+import { VideoModel } from '@server/models/video/video.js'
import { MActorAudience, MActorLight, MVideoImmutable, MVideoUrl } from '@server/types/models/index.js'
import { Transaction } from 'sequelize'
import { logger } from '../../../helpers/logger.js'
import { audiencify, getPublicAudience } from '../audience.js'
import { getLocalVideoViewActivityPubUrl } from '../url.js'
import { sendVideoRelatedActivity } from './shared/send-utils.js'
+import { canVideoBeFederated } from '../videos/index.js'
async function sendView (options: {
byActor: MActorLight
@@ -14,7 +16,10 @@ async function sendView (options: {
viewersCount?: number
transaction?: Transaction
}) {
- const { byActor, viewersCount, video, viewerIdentifier, transaction } = options
+ const { byActor, viewersCount, viewerIdentifier, transaction } = options
+
+ const video = await VideoModel.loadWithRights(options.video.id, transaction)
+ if (!canVideoBeFederated(video)) return undefined
logger.info('Creating job to send %s of %s.', viewersCount !== undefined ? 'viewer' : 'view', video.url)
diff --git a/server/core/lib/activitypub/send/shared/send-utils.ts b/server/core/lib/activitypub/send/shared/send-utils.ts
index 11dd5f93e3..6cd6d4ca0a 100644
--- a/server/core/lib/activitypub/send/shared/send-utils.ts
+++ b/server/core/lib/activitypub/send/shared/send-utils.ts
@@ -22,20 +22,19 @@ import { getDirectAudience, getVideoAudience } from '../../audience.js'
async function sendVideoRelatedActivity (activityBuilder: (audience: ActivityAudience) => Activity, options: {
byActor: MActorLight
- video: MVideoImmutable | MVideoAccountLight
+ video: MVideoAccountLight
contextType: ContextType
parallelizable?: boolean
transaction?: Transaction
skipPrivacyCheck?: boolean
}) {
- const { byActor, transaction, contextType, parallelizable, skipPrivacyCheck } = options
+ const { byActor, transaction, contextType, parallelizable, video, skipPrivacyCheck } = options
// Send to origin
- if (options.video.isLocal() === false) {
+ if (video.isLocal() === false) {
return sendVideoRelatedActivityToOrigin(activityBuilder, options)
}
- const video = await VideoModel.loadByUrlAndPopulateAccount(options.video.url, transaction)
const actorsInvolvedInVideo = await getActorsInvolvedInVideo(video, transaction)
const audience = getVideoAudience({