diff options
Diffstat (limited to 'server/lib/activitypub/send/send-create.ts')
-rw-r--r-- | server/lib/activitypub/send/send-create.ts | 43 |
1 files changed, 20 insertions, 23 deletions
diff --git a/server/lib/activitypub/send/send-create.ts b/server/lib/activitypub/send/send-create.ts index 3ef4fcd3b..293947b05 100644 --- a/server/lib/activitypub/send/send-create.ts +++ b/server/lib/activitypub/send/send-create.ts | |||
@@ -23,8 +23,8 @@ async function sendCreateVideo (video: VideoModel, t: Transaction) { | |||
23 | const byActor = video.VideoChannel.Account.Actor | 23 | const byActor = video.VideoChannel.Account.Actor |
24 | const videoObject = video.toActivityPubObject() | 24 | const videoObject = video.toActivityPubObject() |
25 | 25 | ||
26 | const audience = await getAudience(byActor, t, video.privacy === VideoPrivacy.PUBLIC) | 26 | const audience = getAudience(byActor, video.privacy === VideoPrivacy.PUBLIC) |
27 | const data = await createActivityData(video.url, byActor, videoObject, t, audience) | 27 | const data = createActivityData(video.url, byActor, videoObject, audience) |
28 | 28 | ||
29 | return broadcastToFollowers(data, byActor, [ byActor ], t) | 29 | return broadcastToFollowers(data, byActor, [ byActor ], t) |
30 | } | 30 | } |
@@ -33,7 +33,7 @@ async function sendVideoAbuse (byActor: ActorModel, videoAbuse: VideoAbuseModel, | |||
33 | const url = getVideoAbuseActivityPubUrl(videoAbuse) | 33 | const url = getVideoAbuseActivityPubUrl(videoAbuse) |
34 | 34 | ||
35 | const audience = { to: [ video.VideoChannel.Account.Actor.url ], cc: [] } | 35 | const audience = { to: [ video.VideoChannel.Account.Actor.url ], cc: [] } |
36 | const data = await createActivityData(url, byActor, videoAbuse.toActivityPubObject(), t, audience) | 36 | const data = createActivityData(url, byActor, videoAbuse.toActivityPubObject(), audience) |
37 | 37 | ||
38 | return unicastTo(data, byActor, video.VideoChannel.Account.Actor.sharedInboxUrl) | 38 | return unicastTo(data, byActor, video.VideoChannel.Account.Actor.sharedInboxUrl) |
39 | } | 39 | } |
@@ -57,7 +57,7 @@ async function sendCreateVideoComment (comment: VideoCommentModel, t: Transactio | |||
57 | audience = getObjectFollowersAudience(actorsInvolvedInComment.concat(parentsCommentActors)) | 57 | audience = getObjectFollowersAudience(actorsInvolvedInComment.concat(parentsCommentActors)) |
58 | } | 58 | } |
59 | 59 | ||
60 | const data = await createActivityData(comment.url, byActor, commentObject, t, audience) | 60 | const data = createActivityData(comment.url, byActor, commentObject, audience) |
61 | 61 | ||
62 | // This was a reply, send it to the parent actors | 62 | // This was a reply, send it to the parent actors |
63 | const actorsException = [ byActor ] | 63 | const actorsException = [ byActor ] |
@@ -82,14 +82,14 @@ async function sendCreateView (byActor: ActorModel, video: VideoModel, t: Transa | |||
82 | // Send to origin | 82 | // Send to origin |
83 | if (video.isOwned() === false) { | 83 | if (video.isOwned() === false) { |
84 | const audience = getVideoAudience(video, actorsInvolvedInVideo) | 84 | const audience = getVideoAudience(video, actorsInvolvedInVideo) |
85 | const data = await createActivityData(url, byActor, viewActivityData, t, audience) | 85 | const data = createActivityData(url, byActor, viewActivityData, audience) |
86 | 86 | ||
87 | return unicastTo(data, byActor, video.VideoChannel.Account.Actor.sharedInboxUrl) | 87 | return unicastTo(data, byActor, video.VideoChannel.Account.Actor.sharedInboxUrl) |
88 | } | 88 | } |
89 | 89 | ||
90 | // Send to followers | 90 | // Send to followers |
91 | const audience = getObjectFollowersAudience(actorsInvolvedInVideo) | 91 | const audience = getObjectFollowersAudience(actorsInvolvedInVideo) |
92 | const data = await createActivityData(url, byActor, viewActivityData, t, audience) | 92 | const data = createActivityData(url, byActor, viewActivityData, audience) |
93 | 93 | ||
94 | // Use the server actor to send the view | 94 | // Use the server actor to send the view |
95 | const serverActor = await getServerActor() | 95 | const serverActor = await getServerActor() |
@@ -106,34 +106,31 @@ async function sendCreateDislike (byActor: ActorModel, video: VideoModel, t: Tra | |||
106 | // Send to origin | 106 | // Send to origin |
107 | if (video.isOwned() === false) { | 107 | if (video.isOwned() === false) { |
108 | const audience = getVideoAudience(video, actorsInvolvedInVideo) | 108 | const audience = getVideoAudience(video, actorsInvolvedInVideo) |
109 | const data = await createActivityData(url, byActor, dislikeActivityData, t, audience) | 109 | const data = createActivityData(url, byActor, dislikeActivityData, audience) |
110 | 110 | ||
111 | return unicastTo(data, byActor, video.VideoChannel.Account.Actor.sharedInboxUrl) | 111 | return unicastTo(data, byActor, video.VideoChannel.Account.Actor.sharedInboxUrl) |
112 | } | 112 | } |
113 | 113 | ||
114 | // Send to followers | 114 | // Send to followers |
115 | const audience = getObjectFollowersAudience(actorsInvolvedInVideo) | 115 | const audience = getObjectFollowersAudience(actorsInvolvedInVideo) |
116 | const data = await createActivityData(url, byActor, dislikeActivityData, t, audience) | 116 | const data = createActivityData(url, byActor, dislikeActivityData, audience) |
117 | 117 | ||
118 | const actorsException = [ byActor ] | 118 | const actorsException = [ byActor ] |
119 | return broadcastToFollowers(data, byActor, actorsInvolvedInVideo, t, actorsException) | 119 | return broadcastToFollowers(data, byActor, actorsInvolvedInVideo, t, actorsException) |
120 | } | 120 | } |
121 | 121 | ||
122 | async function createActivityData (url: string, | 122 | function createActivityData (url: string, byActor: ActorModel, object: any, audience?: ActivityAudience): ActivityCreate { |
123 | byActor: ActorModel, | 123 | if (!audience) audience = getAudience(byActor) |
124 | object: any, | 124 | |
125 | t: Transaction, | 125 | return audiencify( |
126 | audience?: ActivityAudience): Promise<ActivityCreate> { | 126 | { |
127 | if (!audience) { | 127 | type: 'Create' as 'Create', |
128 | audience = await getAudience(byActor, t) | 128 | id: url + '/activity', |
129 | } | 129 | actor: byActor.url, |
130 | 130 | object: audiencify(object, audience) | |
131 | return audiencify({ | 131 | }, |
132 | type: 'Create' as 'Create', | 132 | audience |
133 | id: url + '/activity', | 133 | ) |
134 | actor: byActor.url, | ||
135 | object: audiencify(object, audience) | ||
136 | }, audience) | ||
137 | } | 134 | } |
138 | 135 | ||
139 | function createDislikeActivityData (byActor: ActorModel, video: VideoModel) { | 136 | function createDislikeActivityData (byActor: ActorModel, video: VideoModel) { |