aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/lib/activitypub/send/send-create.ts
diff options
context:
space:
mode:
Diffstat (limited to 'server/lib/activitypub/send/send-create.ts')
-rw-r--r--server/lib/activitypub/send/send-create.ts40
1 files changed, 29 insertions, 11 deletions
diff --git a/server/lib/activitypub/send/send-create.ts b/server/lib/activitypub/send/send-create.ts
index e2ee639d9..9db663be1 100644
--- a/server/lib/activitypub/send/send-create.ts
+++ b/server/lib/activitypub/send/send-create.ts
@@ -8,7 +8,7 @@ import { VideoAbuseModel } from '../../../models/video/video-abuse'
8import { VideoCommentModel } from '../../../models/video/video-comment' 8import { VideoCommentModel } from '../../../models/video/video-comment'
9import { getVideoAbuseActivityPubUrl, getVideoDislikeActivityPubUrl, getVideoViewActivityPubUrl } from '../url' 9import { getVideoAbuseActivityPubUrl, getVideoDislikeActivityPubUrl, getVideoViewActivityPubUrl } from '../url'
10import { 10import {
11 audiencify, broadcastToFollowers, getActorsInvolvedInVideo, getAudience, getObjectFollowersAudience, 11 audiencify, broadcastToActors, broadcastToFollowers, getActorsInvolvedInVideo, getAudience, getObjectFollowersAudience,
12 getOriginVideoAudience, getOriginVideoCommentAudience, 12 getOriginVideoAudience, getOriginVideoCommentAudience,
13 unicastTo 13 unicastTo
14} from './misc' 14} from './misc'
@@ -39,11 +39,20 @@ async function sendCreateVideoCommentToOrigin (comment: VideoCommentModel, t: Tr
39 const threadParentComments = await VideoCommentModel.listThreadParentComments(comment, t) 39 const threadParentComments = await VideoCommentModel.listThreadParentComments(comment, t)
40 const commentObject = comment.toActivityPubObject(threadParentComments) 40 const commentObject = comment.toActivityPubObject(threadParentComments)
41 41
42 const actorsInvolvedInVideo = await getActorsInvolvedInVideo(comment.Video, t) 42 const actorsInvolvedInComment = await getActorsInvolvedInVideo(comment.Video, t)
43 const audience = getOriginVideoCommentAudience(comment, threadParentComments, actorsInvolvedInVideo) 43 actorsInvolvedInComment.push(byActor)
44 const audience = getOriginVideoCommentAudience(comment, threadParentComments, actorsInvolvedInComment)
44 45
45 const data = await createActivityData(comment.url, byActor, commentObject, t, audience) 46 const data = await createActivityData(comment.url, byActor, commentObject, t, audience)
46 47
48 // This was a reply, send it to the parent actors
49 const actorsException = [ byActor ]
50 await broadcastToActors(data, byActor, threadParentComments.map(c => c.Account.Actor), t, actorsException)
51
52 // Broadcast to our followers
53 await broadcastToFollowers(data, byActor, [ byActor ], t)
54
55 // Send to origin
47 return unicastTo(data, byActor, comment.Video.VideoChannel.Account.Actor.sharedInboxUrl, t) 56 return unicastTo(data, byActor, comment.Video.VideoChannel.Account.Actor.sharedInboxUrl, t)
48} 57}
49 58
@@ -52,12 +61,21 @@ async function sendCreateVideoCommentToVideoFollowers (comment: VideoCommentMode
52 const threadParentComments = await VideoCommentModel.listThreadParentComments(comment, t) 61 const threadParentComments = await VideoCommentModel.listThreadParentComments(comment, t)
53 const commentObject = comment.toActivityPubObject(threadParentComments) 62 const commentObject = comment.toActivityPubObject(threadParentComments)
54 63
55 const actorsInvolvedInVideo = await getActorsInvolvedInVideo(comment.Video, t) 64 const actorsInvolvedInComment = await getActorsInvolvedInVideo(comment.Video, t)
56 const audience = getOriginVideoCommentAudience(comment, threadParentComments, actorsInvolvedInVideo) 65 actorsInvolvedInComment.push(byActor)
66
67 const audience = getOriginVideoCommentAudience(comment, threadParentComments, actorsInvolvedInComment)
57 const data = await createActivityData(comment.url, byActor, commentObject, t, audience) 68 const data = await createActivityData(comment.url, byActor, commentObject, t, audience)
58 69
59 const followersException = [ byActor ] 70 // This was a reply, send it to the parent actors
60 return broadcastToFollowers(data, byActor, actorsInvolvedInVideo, t, followersException) 71 const actorsException = [ byActor ]
72 await broadcastToActors(data, byActor, threadParentComments.map(c => c.Account.Actor), t, actorsException)
73
74 // Broadcast to our followers
75 await broadcastToFollowers(data, byActor, [ byActor ], t)
76
77 // Send to actors involved in the comment
78 return broadcastToFollowers(data, byActor, actorsInvolvedInComment, t, actorsException)
61} 79}
62 80
63async function sendCreateViewToOrigin (byActor: ActorModel, video: VideoModel, t: Transaction) { 81async function sendCreateViewToOrigin (byActor: ActorModel, video: VideoModel, t: Transaction) {
@@ -81,8 +99,8 @@ async function sendCreateViewToVideoFollowers (byActor: ActorModel, video: Video
81 99
82 // Use the server actor to send the view 100 // Use the server actor to send the view
83 const serverActor = await getServerActor() 101 const serverActor = await getServerActor()
84 const followersException = [ byActor ] 102 const actorsException = [ byActor ]
85 return broadcastToFollowers(data, serverActor, actorsToForwardView, t, followersException) 103 return broadcastToFollowers(data, serverActor, actorsToForwardView, t, actorsException)
86} 104}
87 105
88async function sendCreateDislikeToOrigin (byActor: ActorModel, video: VideoModel, t: Transaction) { 106async function sendCreateDislikeToOrigin (byActor: ActorModel, video: VideoModel, t: Transaction) {
@@ -104,8 +122,8 @@ async function sendCreateDislikeToVideoFollowers (byActor: ActorModel, video: Vi
104 const audience = getObjectFollowersAudience(actorsToForwardView) 122 const audience = getObjectFollowersAudience(actorsToForwardView)
105 const data = await createActivityData(url, byActor, dislikeActivityData, t, audience) 123 const data = await createActivityData(url, byActor, dislikeActivityData, t, audience)
106 124
107 const followersException = [ byActor ] 125 const actorsException = [ byActor ]
108 return broadcastToFollowers(data, byActor, actorsToForwardView, t, followersException) 126 return broadcastToFollowers(data, byActor, actorsToForwardView, t, actorsException)
109} 127}
110 128
111async function createActivityData ( 129async function createActivityData (