diff options
author | Chocobozzz <me@florianbigard.com> | 2019-10-23 11:33:53 +0200 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2019-10-23 11:33:53 +0200 |
commit | 47581df0737ebcc058a5863143c752f9112a4424 (patch) | |
tree | 3b64e3fc49de4bea41d8fd852201ba3abb6b4994 /server/lib/activitypub/send/utils.ts | |
parent | a0e6d267598839c8a5508a65876ce0e07d1b3d74 (diff) | |
download | PeerTube-47581df0737ebcc058a5863143c752f9112a4424.tar.gz PeerTube-47581df0737ebcc058a5863143c752f9112a4424.tar.zst PeerTube-47581df0737ebcc058a5863143c752f9112a4424.zip |
Fix federation with some actors
That don't have a shared inbox, or a URL
Diffstat (limited to 'server/lib/activitypub/send/utils.ts')
-rw-r--r-- | server/lib/activitypub/send/utils.ts | 22 |
1 files changed, 11 insertions, 11 deletions
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 | } |