diff options
author | Chocobozzz <me@florianbigard.com> | 2018-01-26 15:49:57 +0100 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2018-01-26 15:49:57 +0100 |
commit | 4ba3b8ea1be85d95a508ac479f26b96ceea15971 (patch) | |
tree | f76de3c6ec591cf885e5000f0e369aab883f3d95 /server/lib/activitypub/send | |
parent | 7859b5800c08c15f3380fb3a7e267ce1b3f2df9f (diff) | |
download | PeerTube-4ba3b8ea1be85d95a508ac479f26b96ceea15971.tar.gz PeerTube-4ba3b8ea1be85d95a508ac479f26b96ceea15971.tar.zst PeerTube-4ba3b8ea1be85d95a508ac479f26b96ceea15971.zip |
Don't rehost announced video activities
Diffstat (limited to 'server/lib/activitypub/send')
-rw-r--r-- | server/lib/activitypub/send/send-announce.ts | 35 |
1 files changed, 6 insertions, 29 deletions
diff --git a/server/lib/activitypub/send/send-announce.ts b/server/lib/activitypub/send/send-announce.ts index 76cb3f80c..ed551a2b2 100644 --- a/server/lib/activitypub/send/send-announce.ts +++ b/server/lib/activitypub/send/send-announce.ts | |||
@@ -2,45 +2,23 @@ import { Transaction } from 'sequelize' | |||
2 | import { ActivityAnnounce, ActivityAudience } from '../../../../shared/models/activitypub' | 2 | import { ActivityAnnounce, ActivityAudience } from '../../../../shared/models/activitypub' |
3 | import { ActorModel } from '../../../models/activitypub/actor' | 3 | import { ActorModel } from '../../../models/activitypub/actor' |
4 | import { VideoModel } from '../../../models/video/video' | 4 | import { VideoModel } from '../../../models/video/video' |
5 | import { getAnnounceActivityPubUrl } from '../url' | 5 | import { VideoShareModel } from '../../../models/video/video-share' |
6 | import { | 6 | import { broadcastToFollowers, getActorsInvolvedInVideo, getAudience, getObjectFollowersAudience } from './misc' |
7 | broadcastToFollowers, | ||
8 | getActorsInvolvedInVideo, | ||
9 | getAudience, | ||
10 | getObjectFollowersAudience, | ||
11 | getOriginVideoAudience, | ||
12 | unicastTo | ||
13 | } from './misc' | ||
14 | import { createActivityData } from './send-create' | ||
15 | 7 | ||
16 | async function buildVideoAnnounceToFollowers (byActor: ActorModel, video: VideoModel, t: Transaction) { | 8 | async function buildVideoAnnounceToFollowers (byActor: ActorModel, videoShare: VideoShareModel, video: VideoModel, t: Transaction) { |
17 | const url = getAnnounceActivityPubUrl(video.url, byActor) | ||
18 | const announcedObject = video.url | 9 | const announcedObject = video.url |
19 | 10 | ||
20 | const accountsToForwardView = await getActorsInvolvedInVideo(video, t) | 11 | const accountsToForwardView = await getActorsInvolvedInVideo(video, t) |
21 | const audience = getObjectFollowersAudience(accountsToForwardView) | 12 | const audience = getObjectFollowersAudience(accountsToForwardView) |
22 | return announceActivityData(url, byActor, announcedObject, t, audience) | 13 | return announceActivityData(videoShare.url, byActor, announcedObject, t, audience) |
23 | } | 14 | } |
24 | 15 | ||
25 | async function sendVideoAnnounceToFollowers (byActor: ActorModel, video: VideoModel, t: Transaction) { | 16 | async function sendVideoAnnounceToFollowers (byActor: ActorModel, videoShare: VideoShareModel, video: VideoModel, t: Transaction) { |
26 | const data = await buildVideoAnnounceToFollowers(byActor, video, t) | 17 | const data = await buildVideoAnnounceToFollowers(byActor, videoShare, video, t) |
27 | 18 | ||
28 | return broadcastToFollowers(data, byActor, [ byActor ], t) | 19 | return broadcastToFollowers(data, byActor, [ byActor ], t) |
29 | } | 20 | } |
30 | 21 | ||
31 | async function sendVideoAnnounceToOrigin (byActor: ActorModel, video: VideoModel, t: Transaction) { | ||
32 | const url = getAnnounceActivityPubUrl(video.url, byActor) | ||
33 | |||
34 | const videoObject = video.toActivityPubObject() | ||
35 | const announcedActivity = await createActivityData(url, video.VideoChannel.Account.Actor, videoObject, t) | ||
36 | |||
37 | const actorsInvolvedInVideo = await getActorsInvolvedInVideo(video, t) | ||
38 | const audience = getOriginVideoAudience(video, actorsInvolvedInVideo) | ||
39 | const data = await createActivityData(url, byActor, announcedActivity, t, audience) | ||
40 | |||
41 | return unicastTo(data, byActor, video.VideoChannel.Account.Actor.sharedInboxUrl) | ||
42 | } | ||
43 | |||
44 | async function announceActivityData ( | 22 | async function announceActivityData ( |
45 | url: string, | 23 | url: string, |
46 | byActor: ActorModel, | 24 | byActor: ActorModel, |
@@ -66,7 +44,6 @@ async function announceActivityData ( | |||
66 | 44 | ||
67 | export { | 45 | export { |
68 | sendVideoAnnounceToFollowers, | 46 | sendVideoAnnounceToFollowers, |
69 | sendVideoAnnounceToOrigin, | ||
70 | announceActivityData, | 47 | announceActivityData, |
71 | buildVideoAnnounceToFollowers | 48 | buildVideoAnnounceToFollowers |
72 | } | 49 | } |