From aa46f5f1bb9e2d5170079282081977a8048b5392 Mon Sep 17 00:00:00 2001 From: Namekuji Date: Fri, 16 Jun 2023 04:36:11 -0400 Subject: [PATCH] skip if actor is not found or has been already deleted --- .../backend/src/queue/processors/db/delete-account.ts | 4 +--- .../backend/src/remote/activitypub/kernel/delete/actor.ts | 8 +++++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/packages/backend/src/queue/processors/db/delete-account.ts b/packages/backend/src/queue/processors/db/delete-account.ts index a356ca7abf..1cd7642ba5 100644 --- a/packages/backend/src/queue/processors/db/delete-account.ts +++ b/packages/backend/src/queue/processors/db/delete-account.ts @@ -17,9 +17,7 @@ export async function deleteAccount( logger.info(`Deleting account of ${job.data.user.id} ...`); const user = await Users.findOneBy({ id: job.data.user.id }); - if (user == null) { - return; - } + if (!user) return; { // Delete notes diff --git a/packages/backend/src/remote/activitypub/kernel/delete/actor.ts b/packages/backend/src/remote/activitypub/kernel/delete/actor.ts index 3571135aa5..83c6442dde 100644 --- a/packages/backend/src/remote/activitypub/kernel/delete/actor.ts +++ b/packages/backend/src/remote/activitypub/kernel/delete/actor.ts @@ -15,9 +15,11 @@ export async function deleteActor( return `skip: delete actor ${actor.uri} !== ${uri}`; } - const user = await Users.findOneByOrFail({ id: actor.id }); - if (user.isDeleted) { - logger.info("skip: already deleted"); + const user = await Users.findOneBy({ id: actor.id }); + if (!user) { + return `skip: actor ${actor.id} not found in the local database`; + } else if (user.isDeleted) { + return `skip: user ${user.id} already deleted`; } const job = await createDeleteAccountJob(actor);