]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blobdiff - server/lib/job-queue/handlers/activitypub-http-unicast.ts
Use worker thread to send HTTP requests
[github/Chocobozzz/PeerTube.git] / server / lib / job-queue / handlers / activitypub-http-unicast.ts
index 585dad671e04f7c5074646920b197a8ac6945836..9e4e84002528abd90471f88afc347d90aa71610f 100644 (file)
@@ -1,13 +1,12 @@
-import * as Bull from 'bull'
+import { Job } from 'bullmq'
+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) {
-  logger.info('Processing ActivityPub unicast in job %d.', job.id)
+async function processActivityPubHttpUnicast (job: Job) {
+  logger.info('Processing ActivityPub unicast in job %s.', job.id)
 
   const payload = job.data as ActivitypubHttpUnicastPayload
   const uri = payload.uri
@@ -19,15 +18,14 @@ async function processActivityPubHttpUnicast (job: Bull.Job) {
     method: 'POST' as 'POST',
     json: body,
     httpSignature: httpSignatureOptions,
-    timeout: REQUEST_TIMEOUT,
     headers: buildGlobalHeaders(body)
   }
 
   try {
     await doRequest(uri, options)
-    ActorFollowScoreCache.Instance.updateActorFollowsScore([ uri ], [])
+    ActorFollowHealthCache.Instance.updateActorFollowsHealth([ uri ], [])
   } catch (err) {
-    ActorFollowScoreCache.Instance.updateActorFollowsScore([], [ uri ])
+    ActorFollowHealthCache.Instance.updateActorFollowsHealth([], [ uri ])
 
     throw err
   }