aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/lib/activitypub/send/send-announce.ts
diff options
context:
space:
mode:
Diffstat (limited to 'server/lib/activitypub/send/send-announce.ts')
-rw-r--r--server/lib/activitypub/send/send-announce.ts35
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'
2import { ActivityAnnounce, ActivityAudience } from '../../../../shared/models/activitypub' 2import { ActivityAnnounce, ActivityAudience } from '../../../../shared/models/activitypub'
3import { ActorModel } from '../../../models/activitypub/actor' 3import { ActorModel } from '../../../models/activitypub/actor'
4import { VideoModel } from '../../../models/video/video' 4import { VideoModel } from '../../../models/video/video'
5import { getAnnounceActivityPubUrl } from '../url' 5import { VideoShareModel } from '../../../models/video/video-share'
6import { 6import { broadcastToFollowers, getActorsInvolvedInVideo, getAudience, getObjectFollowersAudience } from './misc'
7 broadcastToFollowers,
8 getActorsInvolvedInVideo,
9 getAudience,
10 getObjectFollowersAudience,
11 getOriginVideoAudience,
12 unicastTo
13} from './misc'
14import { createActivityData } from './send-create'
15 7
16async function buildVideoAnnounceToFollowers (byActor: ActorModel, video: VideoModel, t: Transaction) { 8async 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
25async function sendVideoAnnounceToFollowers (byActor: ActorModel, video: VideoModel, t: Transaction) { 16async 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
31async 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
44async function announceActivityData ( 22async function announceActivityData (
45 url: string, 23 url: string,
46 byActor: ActorModel, 24 byActor: ActorModel,
@@ -66,7 +44,6 @@ async function announceActivityData (
66 44
67export { 45export {
68 sendVideoAnnounceToFollowers, 46 sendVideoAnnounceToFollowers,
69 sendVideoAnnounceToOrigin,
70 announceActivityData, 47 announceActivityData,
71 buildVideoAnnounceToFollowers 48 buildVideoAnnounceToFollowers
72} 49}