diff options
Diffstat (limited to 'server/lib')
-rw-r--r-- | server/lib/job-queue/handlers/activitypub-http-broadcast.ts | 17 |
1 files changed, 7 insertions, 10 deletions
diff --git a/server/lib/job-queue/handlers/activitypub-http-broadcast.ts b/server/lib/job-queue/handlers/activitypub-http-broadcast.ts index 78878fc01..38b8393f4 100644 --- a/server/lib/job-queue/handlers/activitypub-http-broadcast.ts +++ b/server/lib/job-queue/handlers/activitypub-http-broadcast.ts | |||
@@ -1,8 +1,10 @@ | |||
1 | import * as kue from 'kue' | 1 | import * as kue from 'kue' |
2 | import * as Bluebird from 'bluebird' | ||
2 | import { logger } from '../../../helpers/logger' | 3 | import { logger } from '../../../helpers/logger' |
3 | import { doRequest } from '../../../helpers/requests' | 4 | import { doRequest } from '../../../helpers/requests' |
4 | import { ActorFollowModel } from '../../../models/activitypub/actor-follow' | 5 | import { ActorFollowModel } from '../../../models/activitypub/actor-follow' |
5 | import { buildSignedRequestOptions, computeBody } from './utils/activitypub-http-utils' | 6 | import { buildSignedRequestOptions, computeBody } from './utils/activitypub-http-utils' |
7 | import { BROADCAST_CONCURRENCY } from '../../../initializers' | ||
6 | 8 | ||
7 | export type ActivitypubHttpBroadcastPayload = { | 9 | export type ActivitypubHttpBroadcastPayload = { |
8 | uris: string[] | 10 | uris: string[] |
@@ -28,16 +30,11 @@ async function processActivityPubHttpBroadcast (job: kue.Job) { | |||
28 | const badUrls: string[] = [] | 30 | const badUrls: string[] = [] |
29 | const goodUrls: string[] = [] | 31 | const goodUrls: string[] = [] |
30 | 32 | ||
31 | for (const uri of payload.uris) { | 33 | await Bluebird.map(payload.uris, uri => { |
32 | options.uri = uri | 34 | return doRequest(Object.assign({}, options, { uri })) |
33 | 35 | .then(() => goodUrls.push(uri)) | |
34 | try { | 36 | .catch(() => badUrls.push(uri)) |
35 | await doRequest(options) | 37 | }, { concurrency: BROADCAST_CONCURRENCY }) |
36 | goodUrls.push(uri) | ||
37 | } catch (err) { | ||
38 | badUrls.push(uri) | ||
39 | } | ||
40 | } | ||
41 | 38 | ||
42 | return ActorFollowModel.updateActorFollowsScore(goodUrls, badUrls, undefined) | 39 | return ActorFollowModel.updateActorFollowsScore(goodUrls, badUrls, undefined) |
43 | } | 40 | } |