From a2f99b54dfdfe489e14714681189cb13c89f60a3 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Tue, 16 Nov 2021 10:05:12 +0100 Subject: Optimize AP fetch --- server/lib/activitypub/process/process-announce.ts | 6 +++++- server/lib/activitypub/process/process-create.ts | 3 +++ 2 files changed, 8 insertions(+), 1 deletion(-) (limited to 'server/lib/activitypub/process') diff --git a/server/lib/activitypub/process/process-announce.ts b/server/lib/activitypub/process/process-announce.ts index ec23c705e..2619d9754 100644 --- a/server/lib/activitypub/process/process-announce.ts +++ b/server/lib/activitypub/process/process-announce.ts @@ -8,12 +8,16 @@ import { Notifier } from '../../notifier' import { logger } from '../../../helpers/logger' import { APProcessorOptions } from '../../../types/activitypub-processor.model' import { MActorSignature, MVideoAccountLightBlacklistAllFiles } from '../../../types/models' +import { getAPId } from '@server/helpers/activitypub' async function processAnnounceActivity (options: APProcessorOptions) { const { activity, byActor: actorAnnouncer } = options // Only notify if it is not from a fetcher job const notify = options.fromFetch !== true + // Announces on accounts are not supported + if (actorAnnouncer.type !== 'Application' && actorAnnouncer.type !== 'Group') return + return retryTransactionWrapper(processVideoShare, actorAnnouncer, activity, notify) } @@ -26,7 +30,7 @@ export { // --------------------------------------------------------------------------- async function processVideoShare (actorAnnouncer: MActorSignature, activity: ActivityAnnounce, notify: boolean) { - const objectUri = typeof activity.object === 'string' ? activity.object : activity.object.id + const objectUri = getAPId(activity.object) let video: MVideoAccountLightBlacklistAllFiles let videoCreated: boolean diff --git a/server/lib/activitypub/process/process-create.ts b/server/lib/activitypub/process/process-create.ts index 70e048d6e..93f1d1c59 100644 --- a/server/lib/activitypub/process/process-create.ts +++ b/server/lib/activitypub/process/process-create.ts @@ -28,6 +28,9 @@ async function processCreateActivity (options: APProcessorOptions