-import * as Bull from 'bull'
+import { Job } from 'bull'
+import { buildGlobalHeaders, buildSignedRequestOptions, computeBody } from '@server/lib/activitypub/send'
import { ActivitypubHttpUnicastPayload } from '@shared/models'
import { logger } from '../../../helpers/logger'
import { doRequest } from '../../../helpers/requests'
-import { REQUEST_TIMEOUT } from '../../../initializers/constants'
-import { ActorFollowScoreCache } from '../../files-cache'
-import { buildGlobalHeaders, buildSignedRequestOptions, computeBody } from './utils/activitypub-http-utils'
+import { ActorFollowHealthCache } from '../../actor-follow-health-cache'
-async function processActivityPubHttpUnicast (job: Bull.Job) {
+async function processActivityPubHttpUnicast (job: Job) {
logger.info('Processing ActivityPub unicast in job %d.', job.id)
const payload = job.data as ActivitypubHttpUnicastPayload
const httpSignatureOptions = await buildSignedRequestOptions(payload)
const options = {
- method: 'POST',
- uri,
+ method: 'POST' as 'POST',
json: body,
httpSignature: httpSignatureOptions,
- timeout: REQUEST_TIMEOUT,
headers: buildGlobalHeaders(body)
}
try {
- await doRequest(options)
- ActorFollowScoreCache.Instance.updateActorFollowsScore([ uri ], [])
+ await doRequest(uri, options)
+ ActorFollowHealthCache.Instance.updateActorFollowsHealth([ uri ], [])
} catch (err) {
- ActorFollowScoreCache.Instance.updateActorFollowsScore([], [ uri ])
+ ActorFollowHealthCache.Instance.updateActorFollowsHealth([], [ uri ])
throw err
}