diff options
Diffstat (limited to 'server/lib/activitypub')
-rw-r--r-- | server/lib/activitypub/actor.ts | 12 | ||||
-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 |
5 files changed, 23 insertions, 17 deletions
diff --git a/server/lib/activitypub/actor.ts b/server/lib/activitypub/actor.ts index 13b73077e..cad9af5e0 100644 --- a/server/lib/activitypub/actor.ts +++ b/server/lib/activitypub/actor.ts | |||
@@ -163,9 +163,12 @@ async function updateActorInstance (actorInstance: ActorModel, attributes: Activ | |||
163 | actorInstance.followingCount = followingCount | 163 | actorInstance.followingCount = followingCount |
164 | actorInstance.inboxUrl = attributes.inbox | 164 | actorInstance.inboxUrl = attributes.inbox |
165 | actorInstance.outboxUrl = attributes.outbox | 165 | actorInstance.outboxUrl = attributes.outbox |
166 | actorInstance.sharedInboxUrl = attributes.endpoints.sharedInbox | ||
167 | actorInstance.followersUrl = attributes.followers | 166 | actorInstance.followersUrl = attributes.followers |
168 | actorInstance.followingUrl = attributes.following | 167 | actorInstance.followingUrl = attributes.following |
168 | |||
169 | if (attributes.endpoints && attributes.endpoints.sharedInbox) { | ||
170 | actorInstance.sharedInboxUrl = attributes.endpoints.sharedInbox | ||
171 | } | ||
169 | } | 172 | } |
170 | 173 | ||
171 | type AvatarInfo = { name: string, onDisk: boolean, fileUrl: string } | 174 | type AvatarInfo = { name: string, onDisk: boolean, fileUrl: string } |
@@ -437,9 +440,12 @@ async function fetchRemoteActor (actorUrl: string): Promise<{ statusCode?: numbe | |||
437 | followingCount: followingCount, | 440 | followingCount: followingCount, |
438 | inboxUrl: actorJSON.inbox, | 441 | inboxUrl: actorJSON.inbox, |
439 | outboxUrl: actorJSON.outbox, | 442 | outboxUrl: actorJSON.outbox, |
440 | sharedInboxUrl: actorJSON.endpoints.sharedInbox, | ||
441 | followersUrl: actorJSON.followers, | 443 | followersUrl: actorJSON.followers, |
442 | followingUrl: actorJSON.following | 444 | followingUrl: actorJSON.following, |
445 | |||
446 | sharedInboxUrl: actorJSON.endpoints && actorJSON.endpoints.sharedInbox | ||
447 | ? actorJSON.endpoints.sharedInbox | ||
448 | : null, | ||
443 | }) | 449 | }) |
444 | 450 | ||
445 | const avatarInfo = await getAvatarInfoIfExists(actorJSON) | 451 | const avatarInfo = await getAvatarInfoIfExists(actorJSON) |
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 | } |