From 6104adc3e9d325e003ca1048e8ef35f6a451d0c3 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Tue, 31 Jul 2018 11:15:35 +0200 Subject: [PATCH] Don't send follow request if the follow is already accepted --- CHANGELOG.md | 1 + server/lib/activitypub/actor.ts | 2 +- server/lib/job-queue/handlers/activitypub-follow.ts | 4 ++-- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 8920fbccb..d13c78a4b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -32,6 +32,7 @@ You will need [PostgreSQL Contrib](https://www.postgresql.org/docs/9.6/static/co * Switch job queue to [Bull](https://github.com/OptimalBits/bull). **PeerTube will not migrate your old pending jobs in this new queue manager** * Update nginx template (you need to [update manually](https://github.com/Chocobozzz/PeerTube/blob/develop/support/doc/production.md#nginx)) * Update default cache size configurations + * Update search API route: `/videos/search` becomes `/search/videos` ### Features diff --git a/server/lib/activitypub/actor.ts b/server/lib/activitypub/actor.ts index 7f2fc3236..b67d9f08b 100644 --- a/server/lib/activitypub/actor.ts +++ b/server/lib/activitypub/actor.ts @@ -41,7 +41,7 @@ async function getOrCreateActorAndServerAndModel (activityActor: string | Activi let actor = await ActorModel.loadByUrl(actorUrl) // Orphan actor (not associated to an account of channel) so recreate it - if (!actor.Account && !actor.VideoChannel) { + if (actor && (!actor.Account && !actor.VideoChannel)) { await actor.destroy() actor = null } diff --git a/server/lib/job-queue/handlers/activitypub-follow.ts b/server/lib/job-queue/handlers/activitypub-follow.ts index 2c1b4f49d..393c6936c 100644 --- a/server/lib/job-queue/handlers/activitypub-follow.ts +++ b/server/lib/job-queue/handlers/activitypub-follow.ts @@ -58,7 +58,7 @@ function follow (fromActor: ActorModel, targetActor: ActorModel) { actorFollow.ActorFollowing = targetActor actorFollow.ActorFollower = fromActor - // Send a notification to remote server - await sendFollow(actorFollow) + // Send a notification to remote server if our follow is not already accepted + if (actorFollow.state !== 'accepted') await sendFollow(actorFollow) }) }