From 60650c77c8a2a98e92d869b237ae4900f369a8fc Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Thu, 11 Jan 2018 09:35:50 +0100 Subject: Add scores to follows and remove bad ones --- .../activitypub-http-broadcast-handler.ts | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'server/lib/jobs/activitypub-http-job-scheduler/activitypub-http-broadcast-handler.ts') diff --git a/server/lib/jobs/activitypub-http-job-scheduler/activitypub-http-broadcast-handler.ts b/server/lib/jobs/activitypub-http-job-scheduler/activitypub-http-broadcast-handler.ts index c20a48a4e..3f780e319 100644 --- a/server/lib/jobs/activitypub-http-job-scheduler/activitypub-http-broadcast-handler.ts +++ b/server/lib/jobs/activitypub-http-job-scheduler/activitypub-http-broadcast-handler.ts @@ -1,5 +1,6 @@ import { logger } from '../../../helpers/logger' import { doRequest } from '../../../helpers/requests' +import { ActorFollowModel } from '../../../models/activitypub/actor-follow' import { ActivityPubHttpPayload, buildSignedRequestOptions, computeBody, maybeRetryRequestLater } from './activitypub-http-job-scheduler' async function process (payload: ActivityPubHttpPayload, jobId: number) { @@ -15,15 +16,22 @@ async function process (payload: ActivityPubHttpPayload, jobId: number) { httpSignature: httpSignatureOptions } + const badUrls: string[] = [] + const goodUrls: string[] = [] + for (const uri of payload.uris) { options.uri = uri try { await doRequest(options) + goodUrls.push(uri) } catch (err) { - await maybeRetryRequestLater(err, payload, uri) + const isRetryingLater = await maybeRetryRequestLater(err, payload, uri) + if (isRetryingLater === false) badUrls.push(uri) } } + + return ActorFollowModel.updateActorFollowsScoreAndRemoveBadOnes(goodUrls, badUrls, undefined) } function onError (err: Error, jobId: number) { -- cgit v1.2.3