X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=server%2Flib%2Factivitypub%2Factor.ts;h=f27733418fc83bc176394a0a6bd3f73f92c94742;hb=28be89161aab245526d64f6fb7dd29391a97fe0a;hp=4c336f26ebb2a4418e5c5c18119664b7313629b6;hpb=938d3fa0ffb4cf3e4c88f94dcfcae5eb2ce5e190;p=github%2FChocobozzz%2FPeerTube.git 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' import { AvatarModel } from '../../models/avatar/avatar' import { ServerModel } from '../../models/server/server' import { VideoChannelModel } from '../../models/video/video-channel' +import { JobQueue } from '../job-queue' +import { getServerActor } from '../../helpers/utils' // Set account keys, this could be long so process after the account creation and do not block the client function setAsyncActorKeys (actor: ActorModel) { @@ -169,6 +171,21 @@ async function fetchAvatarIfExists (actorJSON: ActivityPubActor) { return undefined } +async function addFetchOutboxJob (actor: ActorModel) { + // Don't fetch ourselves + const serverActor = await getServerActor() + if (serverActor.id === actor.id) { + logger.error('Cannot fetch our own outbox!') + return undefined + } + + const payload = { + uris: [ actor.outboxUrl ] + } + + return JobQueue.Instance.createJob({ type: 'activitypub-http-fetcher', payload }) +} + export { getOrCreateActorAndServerAndModel, buildActorInstance, @@ -176,7 +193,8 @@ export { fetchActorTotalItems, fetchAvatarIfExists, updateActorInstance, - updateActorAvatarInstance + updateActorAvatarInstance, + addFetchOutboxJob } // ---------------------------------------------------------------------------