]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/commitdiff
Correctly handle actors without follow counters
authorChocobozzz <me@florianbigard.com>
Fri, 15 Jul 2022 09:18:29 +0000 (11:18 +0200)
committerChocobozzz <me@florianbigard.com>
Fri, 15 Jul 2022 09:18:29 +0000 (11:18 +0200)
server/lib/activitypub/actors/shared/url-to-object.ts

index 12a121725bba8fa5014e747f92fed16e11fa2c00..208d108eeea31f4ec47cd3fbbc1a457b4f9eec53 100644 (file)
@@ -27,8 +27,11 @@ async function fetchRemoteActor (actorUrl: string): Promise<{ statusCode: number
 }
 
 async function fetchActorFollowsCount (actorObject: ActivityPubActor) {
-  const followersCount = await fetchActorTotalItems(actorObject.followers)
-  const followingCount = await fetchActorTotalItems(actorObject.following)
+  let followersCount = 0
+  let followingCount = 0
+
+  if (actorObject.followers) followersCount = await fetchActorTotalItems(actorObject.followers)
+  if (actorObject.following) followingCount = await fetchActorTotalItems(actorObject.following)
 
   return { followersCount, followingCount }
 }