From 598edb8af1cc7e5ea3ead1ec9c96c4853b90be36 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Mon, 3 Feb 2020 11:12:29 +0100 Subject: Reduce AP context size on specific activities --- server/lib/job-queue/handlers/activitypub-http-broadcast.ts | 2 ++ server/lib/job-queue/handlers/activitypub-http-unicast.ts | 2 ++ server/lib/job-queue/handlers/utils/activitypub-http-utils.ts | 6 +++--- 3 files changed, 7 insertions(+), 3 deletions(-) (limited to 'server/lib/job-queue/handlers') diff --git a/server/lib/job-queue/handlers/activitypub-http-broadcast.ts b/server/lib/job-queue/handlers/activitypub-http-broadcast.ts index 0ff7b44a0..7d9dd61e9 100644 --- a/server/lib/job-queue/handlers/activitypub-http-broadcast.ts +++ b/server/lib/job-queue/handlers/activitypub-http-broadcast.ts @@ -5,11 +5,13 @@ import { doRequest } from '../../../helpers/requests' import { buildGlobalHeaders, buildSignedRequestOptions, computeBody } from './utils/activitypub-http-utils' import { BROADCAST_CONCURRENCY, JOB_REQUEST_TIMEOUT } from '../../../initializers/constants' import { ActorFollowScoreCache } from '../../files-cache' +import { ContextType } from '@server/helpers/activitypub' export type ActivitypubHttpBroadcastPayload = { uris: string[] signatureActorId?: number body: any + contextType?: ContextType } async function processActivityPubHttpBroadcast (job: Bull.Job) { diff --git a/server/lib/job-queue/handlers/activitypub-http-unicast.ts b/server/lib/job-queue/handlers/activitypub-http-unicast.ts index c70ce3be9..6b71e2891 100644 --- a/server/lib/job-queue/handlers/activitypub-http-unicast.ts +++ b/server/lib/job-queue/handlers/activitypub-http-unicast.ts @@ -4,11 +4,13 @@ import { doRequest } from '../../../helpers/requests' 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: Bull.Job) { diff --git a/server/lib/job-queue/handlers/utils/activitypub-http-utils.ts b/server/lib/job-queue/handlers/utils/activitypub-http-utils.ts index a28f3596f..54b35840d 100644 --- a/server/lib/job-queue/handlers/utils/activitypub-http-utils.ts +++ b/server/lib/job-queue/handlers/utils/activitypub-http-utils.ts @@ -1,11 +1,11 @@ -import { buildSignedActivity } from '../../../../helpers/activitypub' +import { buildSignedActivity, ContextType } from '../../../../helpers/activitypub' import { getServerActor } from '../../../../helpers/utils' import { ActorModel } from '../../../../models/activitypub/actor' import { sha256 } from '../../../../helpers/core-utils' import { HTTP_SIGNATURE } from '../../../../initializers/constants' import { MActor } from '../../../../typings/models' -type Payload = { body: any, signatureActorId?: number } +type Payload = { body: any, contextType?: ContextType, signatureActorId?: number } async function computeBody (payload: Payload) { let body = payload.body @@ -13,7 +13,7 @@ async function computeBody (payload: Payload) { if (payload.signatureActorId) { const actorSignature = await ActorModel.load(payload.signatureActorId) if (!actorSignature) throw new Error('Unknown signature actor id.') - body = await buildSignedActivity(actorSignature, payload.body) + body = await buildSignedActivity(actorSignature, payload.body, payload.contextType) } return body -- cgit v1.2.3