From 2ba387a5acf468e1d3adb546a398ff77b25f8b12 Mon Sep 17 00:00:00 2001 From: Ignas Kiela Date: Thu, 14 Sep 2023 19:04:18 +0300 Subject: [PATCH] Drop deletes from actors that don't exist anymore Mastodon sends delete activities for every single note of an actor after they are deleted, even though it usually sends a delete activity for the actor itself from the start. These messages fail processing since we can't verify the signature anymore (we have deleted the actor together with their notes and keys with the delete activity for the actor itself, and it's obviously not possible to look it up anymore), and stick around in the inbox queue for all of the retries, which can take quite a while. But since we can't have anything from actors that we can't resolve, we can safely ignore the deletion request from them. Changelog: Fixed --- packages/backend/src/queue/processors/inbox.ts | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/packages/backend/src/queue/processors/inbox.ts b/packages/backend/src/queue/processors/inbox.ts index d9e1fdee5..2ccc58969 100644 --- a/packages/backend/src/queue/processors/inbox.ts +++ b/packages/backend/src/queue/processors/inbox.ts @@ -6,7 +6,7 @@ import { registerOrFetchInstanceDoc } from '@/services/register-or-fetch-instanc import { Instances } from '@/models/index.js'; import { apRequestChart, federationChart, instanceChart } from '@/services/chart/index.js'; import { extractPunyHost } from '@/misc/convert-host.js'; -import { getApId } from '@/remote/activitypub/type.js'; +import { getApId, isDelete } from '@/remote/activitypub/type.js'; import { fetchInstanceMetadata } from '@/services/fetch-instance-metadata.js'; import { Resolver } from '@/remote/activitypub/resolver.js'; import { LdSignature } from '@/remote/activitypub/misc/ld-signature.js'; @@ -28,7 +28,14 @@ export default async (job: Bull.Job): Promise => { delete info['@context']; logger.debug(JSON.stringify(info, null, 2)); //#endregion - + if (isDelete(activity)) { + try { + await resolver.resolve(getApId(activity.actor)) + } catch (error) { + logger.info("Dropped deletion request from actor that no longer exists") + return 'ok'; + } + } const validated = await verifyHttpSignature(signature, resolver, getApId(activity.actor)); let authUser = validated.authUser; -- 2.43.0