X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=server%2Flib%2Fjob-queue%2Fhandlers%2Factivitypub-http-unicast.ts;h=6b71e28916c82aa8dd2fa6d0b8a07dfc496458b2;hb=a3b7421abb4192e215aa280418b62e96958c5e42;hp=e1e1824e50dc25578a3cad95297d6c84a9a9f88f;hpb=2e3a0215d051dca1f7c8ef423564c8d37a255f77;p=github%2FChocobozzz%2FPeerTube.git diff --git a/server/lib/job-queue/handlers/activitypub-http-unicast.ts b/server/lib/job-queue/handlers/activitypub-http-unicast.ts index e1e1824e5..6b71e2891 100644 --- a/server/lib/job-queue/handlers/activitypub-http-unicast.ts +++ b/server/lib/job-queue/handlers/activitypub-http-unicast.ts @@ -1,16 +1,19 @@ -import * as kue from 'kue' +import * as Bull from 'bull' import { logger } from '../../../helpers/logger' import { doRequest } from '../../../helpers/requests' -import { ActorFollowModel } from '../../../models/activitypub/actor-follow' -import { buildSignedRequestOptions, computeBody } from './utils/activitypub-http-utils' +import { buildGlobalHeaders, buildSignedRequestOptions, computeBody } from './utils/activitypub-http-utils' +import { JOB_REQUEST_TIMEOUT } from '../../../initializers/constants' +import { ActorFollowScoreCache } from '../../files-cache' +import { ContextType } from '@server/helpers/activitypub' export type ActivitypubHttpUnicastPayload = { uri: string signatureActorId?: number body: any + contextType?: ContextType } -async function processActivityPubHttpUnicast (job: kue.Job) { +async function processActivityPubHttpUnicast (job: Bull.Job) { logger.info('Processing ActivityPub unicast in job %d.', job.id) const payload = job.data as ActivitypubHttpUnicastPayload @@ -23,14 +26,16 @@ async function processActivityPubHttpUnicast (job: kue.Job) { method: 'POST', uri, json: body, - httpSignature: httpSignatureOptions + httpSignature: httpSignatureOptions, + timeout: JOB_REQUEST_TIMEOUT, + headers: buildGlobalHeaders(body) } try { await doRequest(options) - ActorFollowModel.updateActorFollowsScore([ uri ], [], undefined) + ActorFollowScoreCache.Instance.updateActorFollowsScore([ uri ], []) } catch (err) { - ActorFollowModel.updateActorFollowsScore([], [ uri ], undefined) + ActorFollowScoreCache.Instance.updateActorFollowsScore([], [ uri ]) throw err }