X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=server%2Flib%2Factivitypub%2Fprocess%2Fprocess-accept.ts;h=046370b79dc0124366276903110d43c7657ff995;hb=f37dc0dd14d9ce0b59c454c2c1b935fcbe9727e9;hp=b9d906ec94c7afe65e9747509ae672e32e444753;hpb=50d6de9c286abcb34ff4234d56d9cbb803db7665;p=github%2FChocobozzz%2FPeerTube.git diff --git a/server/lib/activitypub/process/process-accept.ts b/server/lib/activitypub/process/process-accept.ts index b9d906ec9..046370b79 100644 --- a/server/lib/activitypub/process/process-accept.ts +++ b/server/lib/activitypub/process/process-accept.ts @@ -1,12 +1,14 @@ import { ActivityAccept } from '../../../../shared/models/activitypub' +import { getActorUrl } from '../../../helpers/activitypub' import { ActorModel } from '../../../models/activitypub/actor' import { ActorFollowModel } from '../../../models/activitypub/actor-follow' -import { addFetchOutboxJob } from '../fetch' +import { addFetchOutboxJob } from '../actor' async function processAcceptActivity (activity: ActivityAccept, inboxActor?: ActorModel) { if (inboxActor === undefined) throw new Error('Need to accept on explicit inbox.') - const targetActor = await ActorModel.loadByUrl(activity.actor) + const actorUrl = getActorUrl(activity.actor) + const targetActor = await ActorModel.loadByUrl(actorUrl) return processAccept(inboxActor, targetActor) } @@ -23,7 +25,9 @@ async function processAccept (actor: ActorModel, targetActor: ActorModel) { const follow = await ActorFollowModel.loadByActorAndTarget(actor.id, targetActor.id) if (!follow) throw new Error('Cannot find associated follow.') - follow.set('state', 'accepted') - await follow.save() - await addFetchOutboxJob(targetActor, undefined) + if (follow.state !== 'accepted') { + follow.set('state', 'accepted') + await follow.save() + await addFetchOutboxJob(targetActor) + } }