diff options
Diffstat (limited to 'server/lib/activitypub/send/send-delete.ts')
-rw-r--r-- | server/lib/activitypub/send/send-delete.ts | 25 |
1 files changed, 12 insertions, 13 deletions
diff --git a/server/lib/activitypub/send/send-delete.ts b/server/lib/activitypub/send/send-delete.ts index 3d1dfb699..479182543 100644 --- a/server/lib/activitypub/send/send-delete.ts +++ b/server/lib/activitypub/send/send-delete.ts | |||
@@ -15,24 +15,23 @@ async function sendDeleteVideo (video: VideoModel, t: Transaction) { | |||
15 | const url = getDeleteActivityPubUrl(video.url) | 15 | const url = getDeleteActivityPubUrl(video.url) |
16 | const byActor = video.VideoChannel.Account.Actor | 16 | const byActor = video.VideoChannel.Account.Actor |
17 | 17 | ||
18 | const data = deleteActivityData(url, video.url, byActor) | 18 | const activity = buildDeleteActivity(url, video.url, byActor) |
19 | 19 | ||
20 | const actorsInvolved = await VideoShareModel.loadActorsByShare(video.id, t) | 20 | const actorsInvolved = await getActorsInvolvedInVideo(video, t) |
21 | actorsInvolved.push(byActor) | ||
22 | 21 | ||
23 | return broadcastToFollowers(data, byActor, actorsInvolved, t) | 22 | return broadcastToFollowers(activity, byActor, actorsInvolved, t) |
24 | } | 23 | } |
25 | 24 | ||
26 | async function sendDeleteActor (byActor: ActorModel, t: Transaction) { | 25 | async function sendDeleteActor (byActor: ActorModel, t: Transaction) { |
27 | logger.info('Creating job to broadcast delete of actor %s.', byActor.url) | 26 | logger.info('Creating job to broadcast delete of actor %s.', byActor.url) |
28 | 27 | ||
29 | const url = getDeleteActivityPubUrl(byActor.url) | 28 | const url = getDeleteActivityPubUrl(byActor.url) |
30 | const data = deleteActivityData(url, byActor.url, byActor) | 29 | const activity = buildDeleteActivity(url, byActor.url, byActor) |
31 | 30 | ||
32 | const actorsInvolved = await VideoShareModel.loadActorsByVideoOwner(byActor.id, t) | 31 | const actorsInvolved = await VideoShareModel.loadActorsByVideoOwner(byActor.id, t) |
33 | actorsInvolved.push(byActor) | 32 | actorsInvolved.push(byActor) |
34 | 33 | ||
35 | return broadcastToFollowers(data, byActor, actorsInvolved, t) | 34 | return broadcastToFollowers(activity, byActor, actorsInvolved, t) |
36 | } | 35 | } |
37 | 36 | ||
38 | async function sendDeleteVideoComment (videoComment: VideoCommentModel, t: Transaction) { | 37 | async function sendDeleteVideoComment (videoComment: VideoCommentModel, t: Transaction) { |
@@ -45,23 +44,23 @@ async function sendDeleteVideoComment (videoComment: VideoCommentModel, t: Trans | |||
45 | const threadParentComments = await VideoCommentModel.listThreadParentComments(videoComment, t) | 44 | const threadParentComments = await VideoCommentModel.listThreadParentComments(videoComment, t) |
46 | 45 | ||
47 | const actorsInvolvedInComment = await getActorsInvolvedInVideo(videoComment.Video, t) | 46 | const actorsInvolvedInComment = await getActorsInvolvedInVideo(videoComment.Video, t) |
48 | actorsInvolvedInComment.push(byActor) | 47 | actorsInvolvedInComment.push(byActor) // Add the actor that commented the video |
49 | 48 | ||
50 | const audience = getVideoCommentAudience(videoComment, threadParentComments, actorsInvolvedInComment, isVideoOrigin) | 49 | const audience = getVideoCommentAudience(videoComment, threadParentComments, actorsInvolvedInComment, isVideoOrigin) |
51 | const data = deleteActivityData(url, videoComment.url, byActor, audience) | 50 | const activity = buildDeleteActivity(url, videoComment.url, byActor, audience) |
52 | 51 | ||
53 | // This was a reply, send it to the parent actors | 52 | // This was a reply, send it to the parent actors |
54 | const actorsException = [ byActor ] | 53 | const actorsException = [ byActor ] |
55 | await broadcastToActors(data, byActor, threadParentComments.map(c => c.Account.Actor), actorsException) | 54 | await broadcastToActors(activity, byActor, threadParentComments.map(c => c.Account.Actor), actorsException) |
56 | 55 | ||
57 | // Broadcast to our followers | 56 | // Broadcast to our followers |
58 | await broadcastToFollowers(data, byActor, [ byActor ], t) | 57 | await broadcastToFollowers(activity, byActor, [ byActor ], t) |
59 | 58 | ||
60 | // Send to actors involved in the comment | 59 | // Send to actors involved in the comment |
61 | if (isVideoOrigin) return broadcastToFollowers(data, byActor, actorsInvolvedInComment, t, actorsException) | 60 | if (isVideoOrigin) return broadcastToFollowers(activity, byActor, actorsInvolvedInComment, t, actorsException) |
62 | 61 | ||
63 | // Send to origin | 62 | // Send to origin |
64 | return unicastTo(data, byActor, videoComment.Video.VideoChannel.Account.Actor.sharedInboxUrl) | 63 | return unicastTo(activity, byActor, videoComment.Video.VideoChannel.Account.Actor.sharedInboxUrl) |
65 | } | 64 | } |
66 | 65 | ||
67 | // --------------------------------------------------------------------------- | 66 | // --------------------------------------------------------------------------- |
@@ -74,7 +73,7 @@ export { | |||
74 | 73 | ||
75 | // --------------------------------------------------------------------------- | 74 | // --------------------------------------------------------------------------- |
76 | 75 | ||
77 | function deleteActivityData (url: string, object: string, byActor: ActorModel, audience?: ActivityAudience): ActivityDelete { | 76 | function buildDeleteActivity (url: string, object: string, byActor: ActorModel, audience?: ActivityAudience): ActivityDelete { |
78 | const activity = { | 77 | const activity = { |
79 | type: 'Delete' as 'Delete', | 78 | type: 'Delete' as 'Delete', |
80 | id: url, | 79 | id: url, |