diff options
Diffstat (limited to 'server/lib/activitypub/send')
-rw-r--r-- | server/lib/activitypub/send/send-create.ts | 2 | ||||
-rw-r--r-- | server/lib/activitypub/send/send-delete.ts | 2 | ||||
-rw-r--r-- | server/lib/activitypub/send/send-flag.ts | 2 | ||||
-rw-r--r-- | server/lib/activitypub/send/utils.ts | 22 |
4 files changed, 14 insertions, 14 deletions
diff --git a/server/lib/activitypub/send/send-create.ts b/server/lib/activitypub/send/send-create.ts index 26ec3e948..edbc14a73 100644 --- a/server/lib/activitypub/send/send-create.ts +++ b/server/lib/activitypub/send/send-create.ts | |||
@@ -100,7 +100,7 @@ async function sendCreateVideoComment (comment: MCommentOwnerVideo, t: Transacti | |||
100 | if (isOrigin) return broadcastToFollowers(createActivity, byActor, actorsInvolvedInComment, t, actorsException) | 100 | if (isOrigin) return broadcastToFollowers(createActivity, byActor, actorsInvolvedInComment, t, actorsException) |
101 | 101 | ||
102 | // Send to origin | 102 | // Send to origin |
103 | t.afterCommit(() => unicastTo(createActivity, byActor, comment.Video.VideoChannel.Account.Actor.sharedInboxUrl)) | 103 | t.afterCommit(() => unicastTo(createActivity, byActor, comment.Video.VideoChannel.Account.Actor.getSharedInbox())) |
104 | } | 104 | } |
105 | 105 | ||
106 | function buildCreateActivity (url: string, byActor: MActorLight, object: any, audience?: ActivityAudience): ActivityCreate { | 106 | function buildCreateActivity (url: string, byActor: MActorLight, object: any, audience?: ActivityAudience): ActivityCreate { |
diff --git a/server/lib/activitypub/send/send-delete.ts b/server/lib/activitypub/send/send-delete.ts index 4b1ff8dc5..a91756ff4 100644 --- a/server/lib/activitypub/send/send-delete.ts +++ b/server/lib/activitypub/send/send-delete.ts | |||
@@ -71,7 +71,7 @@ async function sendDeleteVideoComment (videoComment: MCommentOwnerVideoReply, t: | |||
71 | if (isVideoOrigin) return broadcastToFollowers(activity, byActor, actorsInvolvedInComment, t, actorsException) | 71 | if (isVideoOrigin) return broadcastToFollowers(activity, byActor, actorsInvolvedInComment, t, actorsException) |
72 | 72 | ||
73 | // Send to origin | 73 | // Send to origin |
74 | t.afterCommit(() => unicastTo(activity, byActor, videoComment.Video.VideoChannel.Account.Actor.sharedInboxUrl)) | 74 | t.afterCommit(() => unicastTo(activity, byActor, videoComment.Video.VideoChannel.Account.Actor.getSharedInbox())) |
75 | } | 75 | } |
76 | 76 | ||
77 | async function sendDeleteVideoPlaylist (videoPlaylist: MVideoPlaylistFullSummary, t: Transaction) { | 77 | async function sendDeleteVideoPlaylist (videoPlaylist: MVideoPlaylistFullSummary, t: Transaction) { |
diff --git a/server/lib/activitypub/send/send-flag.ts b/server/lib/activitypub/send/send-flag.ts index 5ae1614ab..da7638a7b 100644 --- a/server/lib/activitypub/send/send-flag.ts +++ b/server/lib/activitypub/send/send-flag.ts | |||
@@ -18,7 +18,7 @@ async function sendVideoAbuse (byActor: MActor, videoAbuse: MVideoAbuseVideo, vi | |||
18 | const audience = { to: [ video.VideoChannel.Account.Actor.url ], cc: [] } | 18 | const audience = { to: [ video.VideoChannel.Account.Actor.url ], cc: [] } |
19 | const flagActivity = buildFlagActivity(url, byActor, videoAbuse, audience) | 19 | const flagActivity = buildFlagActivity(url, byActor, videoAbuse, audience) |
20 | 20 | ||
21 | t.afterCommit(() => unicastTo(flagActivity, byActor, video.VideoChannel.Account.Actor.sharedInboxUrl)) | 21 | t.afterCommit(() => unicastTo(flagActivity, byActor, video.VideoChannel.Account.Actor.getSharedInbox())) |
22 | } | 22 | } |
23 | 23 | ||
24 | function buildFlagActivity (url: string, byActor: MActor, videoAbuse: MVideoAbuseVideo, audience: ActivityAudience): ActivityFlag { | 24 | function buildFlagActivity (url: string, byActor: MActor, videoAbuse: MVideoAbuseVideo, audience: ActivityAudience): ActivityFlag { |
diff --git a/server/lib/activitypub/send/utils.ts b/server/lib/activitypub/send/utils.ts index 8129ab32a..77b723479 100644 --- a/server/lib/activitypub/send/utils.ts +++ b/server/lib/activitypub/send/utils.ts | |||
@@ -7,7 +7,7 @@ import { JobQueue } from '../../job-queue' | |||
7 | import { getActorsInvolvedInVideo, getAudienceFromFollowersOf, getRemoteVideoAudience } from '../audience' | 7 | import { getActorsInvolvedInVideo, getAudienceFromFollowersOf, getRemoteVideoAudience } from '../audience' |
8 | import { getServerActor } from '../../../helpers/utils' | 8 | import { getServerActor } from '../../../helpers/utils' |
9 | import { afterCommitIfTransaction } from '../../../helpers/database-utils' | 9 | import { afterCommitIfTransaction } from '../../../helpers/database-utils' |
10 | import { MActorFollowerException, MActor, MActorId, MActorLight, MVideo, MVideoAccountLight } from '../../../typings/models' | 10 | import { MActorWithInboxes, MActor, MActorId, MActorLight, MVideo, MVideoAccountLight } from '../../../typings/models' |
11 | 11 | ||
12 | async function sendVideoRelatedActivity (activityBuilder: (audience: ActivityAudience) => Activity, options: { | 12 | async function sendVideoRelatedActivity (activityBuilder: (audience: ActivityAudience) => Activity, options: { |
13 | byActor: MActorLight, | 13 | byActor: MActorLight, |
@@ -24,7 +24,7 @@ async function sendVideoRelatedActivity (activityBuilder: (audience: ActivityAud | |||
24 | const activity = activityBuilder(audience) | 24 | const activity = activityBuilder(audience) |
25 | 25 | ||
26 | return afterCommitIfTransaction(transaction, () => { | 26 | return afterCommitIfTransaction(transaction, () => { |
27 | return unicastTo(activity, byActor, video.VideoChannel.Account.Actor.sharedInboxUrl) | 27 | return unicastTo(activity, byActor, video.VideoChannel.Account.Actor.getSharedInbox()) |
28 | }) | 28 | }) |
29 | } | 29 | } |
30 | 30 | ||
@@ -40,7 +40,7 @@ async function sendVideoRelatedActivity (activityBuilder: (audience: ActivityAud | |||
40 | async function forwardVideoRelatedActivity ( | 40 | async function forwardVideoRelatedActivity ( |
41 | activity: Activity, | 41 | activity: Activity, |
42 | t: Transaction, | 42 | t: Transaction, |
43 | followersException: MActorFollowerException[] = [], | 43 | followersException: MActorWithInboxes[] = [], |
44 | video: MVideo | 44 | video: MVideo |
45 | ) { | 45 | ) { |
46 | // Mastodon does not add our announces in audience, so we forward to them manually | 46 | // Mastodon does not add our announces in audience, so we forward to them manually |
@@ -53,7 +53,7 @@ async function forwardVideoRelatedActivity ( | |||
53 | async function forwardActivity ( | 53 | async function forwardActivity ( |
54 | activity: Activity, | 54 | activity: Activity, |
55 | t: Transaction, | 55 | t: Transaction, |
56 | followersException: MActorFollowerException[] = [], | 56 | followersException: MActorWithInboxes[] = [], |
57 | additionalFollowerUrls: string[] = [] | 57 | additionalFollowerUrls: string[] = [] |
58 | ) { | 58 | ) { |
59 | logger.info('Forwarding activity %s.', activity.id) | 59 | logger.info('Forwarding activity %s.', activity.id) |
@@ -90,7 +90,7 @@ async function broadcastToFollowers ( | |||
90 | byActor: MActorId, | 90 | byActor: MActorId, |
91 | toFollowersOf: MActorId[], | 91 | toFollowersOf: MActorId[], |
92 | t: Transaction, | 92 | t: Transaction, |
93 | actorsException: MActorFollowerException[] = [] | 93 | actorsException: MActorWithInboxes[] = [] |
94 | ) { | 94 | ) { |
95 | const uris = await computeFollowerUris(toFollowersOf, actorsException, t) | 95 | const uris = await computeFollowerUris(toFollowersOf, actorsException, t) |
96 | 96 | ||
@@ -102,7 +102,7 @@ async function broadcastToActors ( | |||
102 | byActor: MActorId, | 102 | byActor: MActorId, |
103 | toActors: MActor[], | 103 | toActors: MActor[], |
104 | t?: Transaction, | 104 | t?: Transaction, |
105 | actorsException: MActorFollowerException[] = [] | 105 | actorsException: MActorWithInboxes[] = [] |
106 | ) { | 106 | ) { |
107 | const uris = await computeUris(toActors, actorsException) | 107 | const uris = await computeUris(toActors, actorsException) |
108 | return afterCommitIfTransaction(t, () => broadcastTo(uris, data, byActor)) | 108 | return afterCommitIfTransaction(t, () => broadcastTo(uris, data, byActor)) |
@@ -147,7 +147,7 @@ export { | |||
147 | 147 | ||
148 | // --------------------------------------------------------------------------- | 148 | // --------------------------------------------------------------------------- |
149 | 149 | ||
150 | async function computeFollowerUris (toFollowersOf: MActorId[], actorsException: MActorFollowerException[], t: Transaction) { | 150 | async function computeFollowerUris (toFollowersOf: MActorId[], actorsException: MActorWithInboxes[], t: Transaction) { |
151 | const toActorFollowerIds = toFollowersOf.map(a => a.id) | 151 | const toActorFollowerIds = toFollowersOf.map(a => a.id) |
152 | 152 | ||
153 | const result = await ActorFollowModel.listAcceptedFollowerSharedInboxUrls(toActorFollowerIds, t) | 153 | const result = await ActorFollowModel.listAcceptedFollowerSharedInboxUrls(toActorFollowerIds, t) |
@@ -156,11 +156,11 @@ async function computeFollowerUris (toFollowersOf: MActorId[], actorsException: | |||
156 | return result.data.filter(sharedInbox => sharedInboxesException.indexOf(sharedInbox) === -1) | 156 | return result.data.filter(sharedInbox => sharedInboxesException.indexOf(sharedInbox) === -1) |
157 | } | 157 | } |
158 | 158 | ||
159 | async function computeUris (toActors: MActor[], actorsException: MActorFollowerException[] = []) { | 159 | async function computeUris (toActors: MActor[], actorsException: MActorWithInboxes[] = []) { |
160 | const serverActor = await getServerActor() | 160 | const serverActor = await getServerActor() |
161 | const targetUrls = toActors | 161 | const targetUrls = toActors |
162 | .filter(a => a.id !== serverActor.id) // Don't send to ourselves | 162 | .filter(a => a.id !== serverActor.id) // Don't send to ourselves |
163 | .map(a => a.sharedInboxUrl || a.inboxUrl) | 163 | .map(a => a.getSharedInbox()) |
164 | 164 | ||
165 | const toActorSharedInboxesSet = new Set(targetUrls) | 165 | const toActorSharedInboxesSet = new Set(targetUrls) |
166 | 166 | ||
@@ -169,10 +169,10 @@ async function computeUris (toActors: MActor[], actorsException: MActorFollowerE | |||
169 | .filter(sharedInbox => sharedInboxesException.indexOf(sharedInbox) === -1) | 169 | .filter(sharedInbox => sharedInboxesException.indexOf(sharedInbox) === -1) |
170 | } | 170 | } |
171 | 171 | ||
172 | async function buildSharedInboxesException (actorsException: MActorFollowerException[]) { | 172 | async function buildSharedInboxesException (actorsException: MActorWithInboxes[]) { |
173 | const serverActor = await getServerActor() | 173 | const serverActor = await getServerActor() |
174 | 174 | ||
175 | return actorsException | 175 | return actorsException |
176 | .map(f => f.sharedInboxUrl || f.inboxUrl) | 176 | .map(f => f.getSharedInbox()) |
177 | .concat([ serverActor.sharedInboxUrl ]) | 177 | .concat([ serverActor.sharedInboxUrl ]) |
178 | } | 178 | } |