diff options
author | Chocobozzz <me@florianbigard.com> | 2018-01-08 10:00:35 +0100 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2018-01-08 10:15:27 +0100 |
commit | 93ef8a9d02059da2fc90efedb7755c97e9e19ef4 (patch) | |
tree | dfde0d2fdb63277d94491265171add41acf091c3 /server/lib/activitypub/send/send-create.ts | |
parent | 57a49263e48739c31cd339730ac4cb24e3d5d723 (diff) | |
download | PeerTube-93ef8a9d02059da2fc90efedb7755c97e9e19ef4.tar.gz PeerTube-93ef8a9d02059da2fc90efedb7755c97e9e19ef4.tar.zst PeerTube-93ef8a9d02059da2fc90efedb7755c97e9e19ef4.zip |
Send comment to followers and parents
Diffstat (limited to 'server/lib/activitypub/send/send-create.ts')
-rw-r--r-- | server/lib/activitypub/send/send-create.ts | 40 |
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' | |||
8 | import { VideoCommentModel } from '../../../models/video/video-comment' | 8 | import { VideoCommentModel } from '../../../models/video/video-comment' |
9 | import { getVideoAbuseActivityPubUrl, getVideoDislikeActivityPubUrl, getVideoViewActivityPubUrl } from '../url' | 9 | import { getVideoAbuseActivityPubUrl, getVideoDislikeActivityPubUrl, getVideoViewActivityPubUrl } from '../url' |
10 | import { | 10 | import { |
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 | ||
63 | async function sendCreateViewToOrigin (byActor: ActorModel, video: VideoModel, t: Transaction) { | 81 | async 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 | ||
88 | async function sendCreateDislikeToOrigin (byActor: ActorModel, video: VideoModel, t: Transaction) { | 106 | async 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 | ||
111 | async function createActivityData ( | 129 | async function createActivityData ( |