ActivityPub-federated video streaming platform using P2P directly in your web browser
Fix follows health cache
Chocobozzza81743416252
diff --git a/server/core/lib/activitypub/send/shared/send-utils.ts b/server/core/lib/activitypub/send/shared/send-utils.tsindex fb4f8532a7..9a287da5b1 100644--- a/server/core/lib/activitypub/send/shared/send-utils.ts+++ b/server/core/lib/activitypub/send/shared/send-utils.ts@@ -197,7 +197,7 @@ function broadcastTo (options: {// Bad URIs could be slow to respond, prefer to process them in a dedicated queuefor (const uri of uris) {- if (ActorFollowHealthCache.Instance.isBadInbox(uri)) {+ if (ActorFollowHealthCache.Instance.isLastBadInbox(uri)) {unicastUris.push(uri)} else {broadcastUris.push(uri)diff --git a/server/core/lib/actor-follow-health-cache.ts b/server/core/lib/actor-follow-health-cache.tsindex 7d8c248897..5adf809336 100644--- a/server/core/lib/actor-follow-health-cache.ts+++ b/server/core/lib/actor-follow-health-cache.ts@@ -1,4 +1,3 @@-import { ACTOR_FOLLOW_SCORE } from '../initializers/constants.js'import { logger } from '../helpers/logger.js'// Cache follows scores, instead of writing them too often in database@@ -6,14 +5,14 @@ import { logger } from '../helpers/logger.js'export class ActorFollowHealthCache {private static instance: ActorFollowHealthCache- private pendingFollowsScore: { [url: string]: number } = {}-private readonly pendingBadServer = new Set<number>()private readonly pendingGoodServer = new Set<number>()private readonly badInboxes = new Set<string>()private readonly goodInboxes = new Set<string>()+ private readonly lastBatchBadInboxes = new Set<string>()+private constructor () {}static get Instance () {@@ -21,7 +20,7 @@ export class ActorFollowHealthCache {}updateActorFollowsHealth (goodInboxes: string[], badInboxes: string[]) {- this.badInboxes.clear()+ this.lastBatchBadInboxes.clear()if (goodInboxes.length === 0 && badInboxes.length === 0) return@@ -33,23 +32,21 @@ export class ActorFollowHealthCache {)for (const goodInbox of goodInboxes) {- if (this.pendingFollowsScore[goodInbox] === undefined) this.pendingFollowsScore[goodInbox] = 0-- this.pendingFollowsScore[goodInbox] += ACTOR_FOLLOW_SCORE.BONUS+ this.goodInboxes.add(goodInbox)}for (const badInbox of badInboxes) {- if (this.pendingFollowsScore[badInbox] === undefined) this.pendingFollowsScore[badInbox] = 0-- this.pendingFollowsScore[badInbox] += ACTOR_FOLLOW_SCORE.PENALTYthis.badInboxes.add(badInbox)+ this.lastBatchBadInboxes.add(badInbox)}}- isBadInbox (inboxUrl: string) {- return this.badInboxes.has(inboxUrl)+ isLastBadInbox (inboxUrl: string) {+ return this.lastBatchBadInboxes.has(inboxUrl)}+ // ---------------------------------------------------------------------------+getBadInboxes () {return new Set(this.badInboxes)}