diff options
author | Chocobozzz <me@florianbigard.com> | 2018-01-12 10:02:11 +0100 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2018-01-12 10:02:11 +0100 |
commit | 6502c3d43e512e968ad49f5a3bc9abc302471e18 (patch) | |
tree | 32f7a95080a7fa17198dc2556226dea5eb4c93b8 /server/lib/jobs | |
parent | 9a8cbd8278a37ee414f17d7de7c7281123484ba1 (diff) | |
download | PeerTube-6502c3d43e512e968ad49f5a3bc9abc302471e18.tar.gz PeerTube-6502c3d43e512e968ad49f5a3bc9abc302471e18.tar.zst PeerTube-6502c3d43e512e968ad49f5a3bc9abc302471e18.zip |
Avoid making retried requests to dead followers
Diffstat (limited to 'server/lib/jobs')
-rw-r--r-- | server/lib/jobs/activitypub-http-job-scheduler/activitypub-http-job-scheduler.ts | 7 | ||||
-rw-r--r-- | server/lib/jobs/activitypub-http-job-scheduler/activitypub-http-unicast-handler.ts | 3 |
2 files changed, 9 insertions, 1 deletions
diff --git a/server/lib/jobs/activitypub-http-job-scheduler/activitypub-http-job-scheduler.ts b/server/lib/jobs/activitypub-http-job-scheduler/activitypub-http-job-scheduler.ts index 10423a7df..4459152db 100644 --- a/server/lib/jobs/activitypub-http-job-scheduler/activitypub-http-job-scheduler.ts +++ b/server/lib/jobs/activitypub-http-job-scheduler/activitypub-http-job-scheduler.ts | |||
@@ -4,6 +4,7 @@ import { logger } from '../../../helpers/logger' | |||
4 | import { getServerActor } from '../../../helpers/utils' | 4 | import { getServerActor } from '../../../helpers/utils' |
5 | import { ACTIVITY_PUB } from '../../../initializers' | 5 | import { ACTIVITY_PUB } from '../../../initializers' |
6 | import { ActorModel } from '../../../models/activitypub/actor' | 6 | import { ActorModel } from '../../../models/activitypub/actor' |
7 | import { ActorFollowModel } from '../../../models/activitypub/actor-follow' | ||
7 | import { JobHandler, JobScheduler } from '../job-scheduler' | 8 | import { JobHandler, JobScheduler } from '../job-scheduler' |
8 | 9 | ||
9 | import * as activitypubHttpBroadcastHandler from './activitypub-http-broadcast-handler' | 10 | import * as activitypubHttpBroadcastHandler from './activitypub-http-broadcast-handler' |
@@ -35,6 +36,12 @@ async function maybeRetryRequestLater (err: Error, payload: ActivityPubHttpPaylo | |||
35 | if (attemptNumber < ACTIVITY_PUB.MAX_HTTP_ATTEMPT) { | 36 | if (attemptNumber < ACTIVITY_PUB.MAX_HTTP_ATTEMPT) { |
36 | logger.debug('Retrying request to %s (attempt %d/%d).', uri, attemptNumber, ACTIVITY_PUB.MAX_HTTP_ATTEMPT, err) | 37 | logger.debug('Retrying request to %s (attempt %d/%d).', uri, attemptNumber, ACTIVITY_PUB.MAX_HTTP_ATTEMPT, err) |
37 | 38 | ||
39 | const actor = await ActorFollowModel.loadByFollowerInbox(uri, undefined) | ||
40 | if (!actor) { | ||
41 | logger.debug('Actor %s is not a follower, do not retry the request.', uri) | ||
42 | return false | ||
43 | } | ||
44 | |||
38 | const newPayload = Object.assign(payload, { | 45 | const newPayload = Object.assign(payload, { |
39 | uris: [ uri ], | 46 | uris: [ uri ], |
40 | attemptNumber | 47 | attemptNumber |
diff --git a/server/lib/jobs/activitypub-http-job-scheduler/activitypub-http-unicast-handler.ts b/server/lib/jobs/activitypub-http-job-scheduler/activitypub-http-unicast-handler.ts index deedf8402..54a7504e8 100644 --- a/server/lib/jobs/activitypub-http-job-scheduler/activitypub-http-unicast-handler.ts +++ b/server/lib/jobs/activitypub-http-job-scheduler/activitypub-http-unicast-handler.ts | |||
@@ -6,10 +6,11 @@ import { ActivityPubHttpPayload, buildSignedRequestOptions, computeBody, maybeRe | |||
6 | async function process (payload: ActivityPubHttpPayload, jobId: number) { | 6 | async function process (payload: ActivityPubHttpPayload, jobId: number) { |
7 | logger.info('Processing ActivityPub unicast in job %d.', jobId) | 7 | logger.info('Processing ActivityPub unicast in job %d.', jobId) |
8 | 8 | ||
9 | const uri = payload.uris[0] | ||
10 | |||
9 | const body = await computeBody(payload) | 11 | const body = await computeBody(payload) |
10 | const httpSignatureOptions = await buildSignedRequestOptions(payload) | 12 | const httpSignatureOptions = await buildSignedRequestOptions(payload) |
11 | 13 | ||
12 | const uri = payload.uris[0] | ||
13 | const options = { | 14 | const options = { |
14 | method: 'POST', | 15 | method: 'POST', |
15 | uri, | 16 | uri, |