diff options
Diffstat (limited to 'server/lib/activitypub/send/send-delete.ts')
-rw-r--r-- | server/lib/activitypub/send/send-delete.ts | 67 |
1 files changed, 54 insertions, 13 deletions
diff --git a/server/lib/activitypub/send/send-delete.ts b/server/lib/activitypub/send/send-delete.ts index 39216cdeb..0d85d9001 100644 --- a/server/lib/activitypub/send/send-delete.ts +++ b/server/lib/activitypub/send/send-delete.ts | |||
@@ -23,16 +23,16 @@ async function sendDeleteVideo (video: MVideoAccountLight, transaction: Transact | |||
23 | return buildDeleteActivity(url, video.url, byActor, audience) | 23 | return buildDeleteActivity(url, video.url, byActor, audience) |
24 | } | 24 | } |
25 | 25 | ||
26 | return sendVideoRelatedActivity(activityBuilder, { byActor, video, transaction }) | 26 | return sendVideoRelatedActivity(activityBuilder, { byActor, video, contextType: 'Delete', transaction }) |
27 | } | 27 | } |
28 | 28 | ||
29 | async function sendDeleteActor (byActor: ActorModel, t: Transaction) { | 29 | async function sendDeleteActor (byActor: ActorModel, transaction: Transaction) { |
30 | logger.info('Creating job to broadcast delete of actor %s.', byActor.url) | 30 | logger.info('Creating job to broadcast delete of actor %s.', byActor.url) |
31 | 31 | ||
32 | const url = getDeleteActivityPubUrl(byActor.url) | 32 | const url = getDeleteActivityPubUrl(byActor.url) |
33 | const activity = buildDeleteActivity(url, byActor.url, byActor) | 33 | const activity = buildDeleteActivity(url, byActor.url, byActor) |
34 | 34 | ||
35 | const actorsInvolved = await VideoShareModel.loadActorsWhoSharedVideosOf(byActor.id, t) | 35 | const actorsInvolved = await VideoShareModel.loadActorsWhoSharedVideosOf(byActor.id, transaction) |
36 | 36 | ||
37 | // In case the actor did not have any videos | 37 | // In case the actor did not have any videos |
38 | const serverActor = await getServerActor() | 38 | const serverActor = await getServerActor() |
@@ -40,10 +40,16 @@ async function sendDeleteActor (byActor: ActorModel, t: Transaction) { | |||
40 | 40 | ||
41 | actorsInvolved.push(byActor) | 41 | actorsInvolved.push(byActor) |
42 | 42 | ||
43 | return broadcastToFollowers(activity, byActor, actorsInvolved, t) | 43 | return broadcastToFollowers({ |
44 | data: activity, | ||
45 | byActor, | ||
46 | toFollowersOf: actorsInvolved, | ||
47 | contextType: 'Delete', | ||
48 | transaction | ||
49 | }) | ||
44 | } | 50 | } |
45 | 51 | ||
46 | async function sendDeleteVideoComment (videoComment: MCommentOwnerVideo, t: Transaction) { | 52 | async function sendDeleteVideoComment (videoComment: MCommentOwnerVideo, transaction: Transaction) { |
47 | logger.info('Creating job to send delete of comment %s.', videoComment.url) | 53 | logger.info('Creating job to send delete of comment %s.', videoComment.url) |
48 | 54 | ||
49 | const isVideoOrigin = videoComment.Video.isOwned() | 55 | const isVideoOrigin = videoComment.Video.isOwned() |
@@ -53,10 +59,10 @@ async function sendDeleteVideoComment (videoComment: MCommentOwnerVideo, t: Tran | |||
53 | ? videoComment.Account.Actor | 59 | ? videoComment.Account.Actor |
54 | : videoComment.Video.VideoChannel.Account.Actor | 60 | : videoComment.Video.VideoChannel.Account.Actor |
55 | 61 | ||
56 | const threadParentComments = await VideoCommentModel.listThreadParentComments(videoComment, t) | 62 | const threadParentComments = await VideoCommentModel.listThreadParentComments(videoComment, transaction) |
57 | const threadParentCommentsFiltered = threadParentComments.filter(c => !c.isDeleted()) | 63 | const threadParentCommentsFiltered = threadParentComments.filter(c => !c.isDeleted()) |
58 | 64 | ||
59 | const actorsInvolvedInComment = await getActorsInvolvedInVideo(videoComment.Video, t) | 65 | const actorsInvolvedInComment = await getActorsInvolvedInVideo(videoComment.Video, transaction) |
60 | actorsInvolvedInComment.push(byActor) // Add the actor that commented the video | 66 | actorsInvolvedInComment.push(byActor) // Add the actor that commented the video |
61 | 67 | ||
62 | const audience = getVideoCommentAudience(videoComment, threadParentCommentsFiltered, actorsInvolvedInComment, isVideoOrigin) | 68 | const audience = getVideoCommentAudience(videoComment, threadParentCommentsFiltered, actorsInvolvedInComment, isVideoOrigin) |
@@ -64,19 +70,48 @@ async function sendDeleteVideoComment (videoComment: MCommentOwnerVideo, t: Tran | |||
64 | 70 | ||
65 | // This was a reply, send it to the parent actors | 71 | // This was a reply, send it to the parent actors |
66 | const actorsException = [ byActor ] | 72 | const actorsException = [ byActor ] |
67 | await broadcastToActors(activity, byActor, threadParentCommentsFiltered.map(c => c.Account.Actor), t, actorsException) | 73 | await broadcastToActors({ |
74 | data: activity, | ||
75 | byActor, | ||
76 | toActors: threadParentCommentsFiltered.map(c => c.Account.Actor), | ||
77 | transaction, | ||
78 | contextType: 'Delete', | ||
79 | actorsException | ||
80 | }) | ||
68 | 81 | ||
69 | // Broadcast to our followers | 82 | // Broadcast to our followers |
70 | await broadcastToFollowers(activity, byActor, [ byActor ], t) | 83 | await broadcastToFollowers({ |
84 | data: activity, | ||
85 | byActor, | ||
86 | toFollowersOf: [ byActor ], | ||
87 | contextType: 'Delete', | ||
88 | transaction | ||
89 | }) | ||
71 | 90 | ||
72 | // Send to actors involved in the comment | 91 | // Send to actors involved in the comment |
73 | if (isVideoOrigin) return broadcastToFollowers(activity, byActor, actorsInvolvedInComment, t, actorsException) | 92 | if (isVideoOrigin) { |
93 | return broadcastToFollowers({ | ||
94 | data: activity, | ||
95 | byActor, | ||
96 | toFollowersOf: actorsInvolvedInComment, | ||
97 | transaction, | ||
98 | contextType: 'Delete', | ||
99 | actorsException | ||
100 | }) | ||
101 | } | ||
74 | 102 | ||
75 | // Send to origin | 103 | // Send to origin |
76 | t.afterCommit(() => unicastTo(activity, byActor, videoComment.Video.VideoChannel.Account.Actor.getSharedInbox())) | 104 | return transaction.afterCommit(() => { |
105 | return unicastTo({ | ||
106 | data: activity, | ||
107 | byActor, | ||
108 | toActorUrl: videoComment.Video.VideoChannel.Account.Actor.getSharedInbox(), | ||
109 | contextType: 'Delete' | ||
110 | }) | ||
111 | }) | ||
77 | } | 112 | } |
78 | 113 | ||
79 | async function sendDeleteVideoPlaylist (videoPlaylist: MVideoPlaylistFullSummary, t: Transaction) { | 114 | async function sendDeleteVideoPlaylist (videoPlaylist: MVideoPlaylistFullSummary, transaction: Transaction) { |
80 | logger.info('Creating job to send delete of playlist %s.', videoPlaylist.url) | 115 | logger.info('Creating job to send delete of playlist %s.', videoPlaylist.url) |
81 | 116 | ||
82 | const byActor = videoPlaylist.OwnerAccount.Actor | 117 | const byActor = videoPlaylist.OwnerAccount.Actor |
@@ -89,7 +124,13 @@ async function sendDeleteVideoPlaylist (videoPlaylist: MVideoPlaylistFullSummary | |||
89 | 124 | ||
90 | if (videoPlaylist.VideoChannel) toFollowersOf.push(videoPlaylist.VideoChannel.Actor) | 125 | if (videoPlaylist.VideoChannel) toFollowersOf.push(videoPlaylist.VideoChannel.Actor) |
91 | 126 | ||
92 | return broadcastToFollowers(activity, byActor, toFollowersOf, t) | 127 | return broadcastToFollowers({ |
128 | data: activity, | ||
129 | byActor, | ||
130 | toFollowersOf, | ||
131 | contextType: 'Delete', | ||
132 | transaction | ||
133 | }) | ||
93 | } | 134 | } |
94 | 135 | ||
95 | // --------------------------------------------------------------------------- | 136 | // --------------------------------------------------------------------------- |