diff options
Diffstat (limited to 'server/lib/activitypub/send/utils.ts')
-rw-r--r-- | server/lib/activitypub/send/utils.ts | 21 |
1 files changed, 18 insertions, 3 deletions
diff --git a/server/lib/activitypub/send/utils.ts b/server/lib/activitypub/send/utils.ts index 0d28444ec..da437292e 100644 --- a/server/lib/activitypub/send/utils.ts +++ b/server/lib/activitypub/send/utils.ts | |||
@@ -6,6 +6,7 @@ import { ActorFollowModel } from '../../../models/activitypub/actor-follow' | |||
6 | import { JobQueue } from '../../job-queue' | 6 | import { JobQueue } from '../../job-queue' |
7 | import { VideoModel } from '../../../models/video/video' | 7 | import { VideoModel } from '../../../models/video/video' |
8 | import { getActorsInvolvedInVideo } from '../audience' | 8 | import { getActorsInvolvedInVideo } from '../audience' |
9 | import { getServerActor } from '../../../helpers/utils' | ||
9 | 10 | ||
10 | async function forwardVideoRelatedActivity ( | 11 | async function forwardVideoRelatedActivity ( |
11 | activity: Activity, | 12 | activity: Activity, |
@@ -118,14 +119,28 @@ async function computeFollowerUris (toActorFollower: ActorModel[], actorsExcepti | |||
118 | const toActorFollowerIds = toActorFollower.map(a => a.id) | 119 | const toActorFollowerIds = toActorFollower.map(a => a.id) |
119 | 120 | ||
120 | const result = await ActorFollowModel.listAcceptedFollowerSharedInboxUrls(toActorFollowerIds, t) | 121 | const result = await ActorFollowModel.listAcceptedFollowerSharedInboxUrls(toActorFollowerIds, t) |
121 | const sharedInboxesException = actorsException.map(f => f.sharedInboxUrl || f.inboxUrl) | 122 | const sharedInboxesException = await buildSharedInboxesException(actorsException) |
123 | |||
122 | return result.data.filter(sharedInbox => sharedInboxesException.indexOf(sharedInbox) === -1) | 124 | return result.data.filter(sharedInbox => sharedInboxesException.indexOf(sharedInbox) === -1) |
123 | } | 125 | } |
124 | 126 | ||
125 | async function computeUris (toActors: ActorModel[], actorsException: ActorModel[] = []) { | 127 | async function computeUris (toActors: ActorModel[], actorsException: ActorModel[] = []) { |
126 | const toActorSharedInboxesSet = new Set(toActors.map(a => a.sharedInboxUrl || a.inboxUrl)) | 128 | const serverActor = await getServerActor() |
129 | const targetUrls = toActors | ||
130 | .filter(a => a.id !== serverActor.id) // Don't send to ourselves | ||
131 | .map(a => a.sharedInboxUrl || a.inboxUrl) | ||
132 | |||
133 | const toActorSharedInboxesSet = new Set(targetUrls) | ||
127 | 134 | ||
128 | const sharedInboxesException = actorsException.map(f => f.sharedInboxUrl || f.inboxUrl) | 135 | const sharedInboxesException = await buildSharedInboxesException(actorsException) |
129 | return Array.from(toActorSharedInboxesSet) | 136 | return Array.from(toActorSharedInboxesSet) |
130 | .filter(sharedInbox => sharedInboxesException.indexOf(sharedInbox) === -1) | 137 | .filter(sharedInbox => sharedInboxesException.indexOf(sharedInbox) === -1) |
131 | } | 138 | } |
139 | |||
140 | async function buildSharedInboxesException (actorsException: ActorModel[]) { | ||
141 | const serverActor = await getServerActor() | ||
142 | |||
143 | return actorsException | ||
144 | .map(f => f.sharedInboxUrl || f.inboxUrl) | ||
145 | .concat([ serverActor.sharedInboxUrl ]) | ||
146 | } | ||