diff options
Diffstat (limited to 'server/lib/activitypub')
-rw-r--r-- | server/lib/activitypub/actor.ts | 20 | ||||
-rw-r--r-- | server/lib/activitypub/fetch.ts | 23 | ||||
-rw-r--r-- | server/lib/activitypub/process/process-accept.ts | 2 | ||||
-rw-r--r-- | server/lib/activitypub/send/misc.ts | 4 |
4 files changed, 21 insertions, 28 deletions
diff --git a/server/lib/activitypub/actor.ts b/server/lib/activitypub/actor.ts index 4c336f26e..f27733418 100644 --- a/server/lib/activitypub/actor.ts +++ b/server/lib/activitypub/actor.ts | |||
@@ -19,6 +19,8 @@ import { ActorModel } from '../../models/activitypub/actor' | |||
19 | import { AvatarModel } from '../../models/avatar/avatar' | 19 | import { AvatarModel } from '../../models/avatar/avatar' |
20 | import { ServerModel } from '../../models/server/server' | 20 | import { ServerModel } from '../../models/server/server' |
21 | import { VideoChannelModel } from '../../models/video/video-channel' | 21 | import { VideoChannelModel } from '../../models/video/video-channel' |
22 | import { JobQueue } from '../job-queue' | ||
23 | import { getServerActor } from '../../helpers/utils' | ||
22 | 24 | ||
23 | // Set account keys, this could be long so process after the account creation and do not block the client | 25 | // Set account keys, this could be long so process after the account creation and do not block the client |
24 | function setAsyncActorKeys (actor: ActorModel) { | 26 | function setAsyncActorKeys (actor: ActorModel) { |
@@ -169,6 +171,21 @@ async function fetchAvatarIfExists (actorJSON: ActivityPubActor) { | |||
169 | return undefined | 171 | return undefined |
170 | } | 172 | } |
171 | 173 | ||
174 | async function addFetchOutboxJob (actor: ActorModel) { | ||
175 | // Don't fetch ourselves | ||
176 | const serverActor = await getServerActor() | ||
177 | if (serverActor.id === actor.id) { | ||
178 | logger.error('Cannot fetch our own outbox!') | ||
179 | return undefined | ||
180 | } | ||
181 | |||
182 | const payload = { | ||
183 | uris: [ actor.outboxUrl ] | ||
184 | } | ||
185 | |||
186 | return JobQueue.Instance.createJob({ type: 'activitypub-http-fetcher', payload }) | ||
187 | } | ||
188 | |||
172 | export { | 189 | export { |
173 | getOrCreateActorAndServerAndModel, | 190 | getOrCreateActorAndServerAndModel, |
174 | buildActorInstance, | 191 | buildActorInstance, |
@@ -176,7 +193,8 @@ export { | |||
176 | fetchActorTotalItems, | 193 | fetchActorTotalItems, |
177 | fetchAvatarIfExists, | 194 | fetchAvatarIfExists, |
178 | updateActorInstance, | 195 | updateActorInstance, |
179 | updateActorAvatarInstance | 196 | updateActorAvatarInstance, |
197 | addFetchOutboxJob | ||
180 | } | 198 | } |
181 | 199 | ||
182 | // --------------------------------------------------------------------------- | 200 | // --------------------------------------------------------------------------- |
diff --git a/server/lib/activitypub/fetch.ts b/server/lib/activitypub/fetch.ts deleted file mode 100644 index a8eefff80..000000000 --- a/server/lib/activitypub/fetch.ts +++ /dev/null | |||
@@ -1,23 +0,0 @@ | |||
1 | import { logger } from '../../helpers/logger' | ||
2 | import { getServerActor } from '../../helpers/utils' | ||
3 | import { ActorModel } from '../../models/activitypub/actor' | ||
4 | import { JobQueue } from '../job-queue' | ||
5 | |||
6 | async function addFetchOutboxJob (actor: ActorModel) { | ||
7 | // Don't fetch ourselves | ||
8 | const serverActor = await getServerActor() | ||
9 | if (serverActor.id === actor.id) { | ||
10 | logger.error('Cannot fetch our own outbox!') | ||
11 | return undefined | ||
12 | } | ||
13 | |||
14 | const payload = { | ||
15 | uris: [ actor.outboxUrl ] | ||
16 | } | ||
17 | |||
18 | return JobQueue.Instance.createJob({ type: 'activitypub-http-fetcher', payload }) | ||
19 | } | ||
20 | |||
21 | export { | ||
22 | addFetchOutboxJob | ||
23 | } | ||
diff --git a/server/lib/activitypub/process/process-accept.ts b/server/lib/activitypub/process/process-accept.ts index c55b57820..046370b79 100644 --- a/server/lib/activitypub/process/process-accept.ts +++ b/server/lib/activitypub/process/process-accept.ts | |||
@@ -2,7 +2,7 @@ import { ActivityAccept } from '../../../../shared/models/activitypub' | |||
2 | import { getActorUrl } from '../../../helpers/activitypub' | 2 | import { getActorUrl } from '../../../helpers/activitypub' |
3 | import { ActorModel } from '../../../models/activitypub/actor' | 3 | import { ActorModel } from '../../../models/activitypub/actor' |
4 | import { ActorFollowModel } from '../../../models/activitypub/actor-follow' | 4 | import { ActorFollowModel } from '../../../models/activitypub/actor-follow' |
5 | import { addFetchOutboxJob } from '../fetch' | 5 | import { addFetchOutboxJob } from '../actor' |
6 | 6 | ||
7 | async function processAcceptActivity (activity: ActivityAccept, inboxActor?: ActorModel) { | 7 | async function processAcceptActivity (activity: ActivityAccept, inboxActor?: ActorModel) { |
8 | if (inboxActor === undefined) throw new Error('Need to accept on explicit inbox.') | 8 | if (inboxActor === undefined) throw new Error('Need to accept on explicit inbox.') |
diff --git a/server/lib/activitypub/send/misc.ts b/server/lib/activitypub/send/misc.ts index b2d968c9c..646aa9f0a 100644 --- a/server/lib/activitypub/send/misc.ts +++ b/server/lib/activitypub/send/misc.ts | |||
@@ -139,9 +139,7 @@ async function getActorsInvolvedInVideo (video: VideoModel, t: Transaction) { | |||
139 | } | 139 | } |
140 | 140 | ||
141 | async function getAudience (actorSender: ActorModel, t: Transaction, isPublic = true) { | 141 | async function getAudience (actorSender: ActorModel, t: Transaction, isPublic = true) { |
142 | const followerInboxUrls = await actorSender.getFollowerSharedInboxUrls(t) | 142 | return buildAudience([ actorSender.followersUrl ], isPublic) |
143 | |||
144 | return buildAudience(followerInboxUrls, isPublic) | ||
145 | } | 143 | } |
146 | 144 | ||
147 | function buildAudience (followerInboxUrls: string[], isPublic = true) { | 145 | function buildAudience (followerInboxUrls: string[], isPublic = true) { |