From 75c2c105fb50dc6915d40a40859ef5282e1e7c56 Mon Sep 17 00:00:00 2001 From: Namekuji Date: Thu, 13 Apr 2023 11:19:35 -0400 Subject: [PATCH] refactor updating actor and target --- .../src/core/activitypub/ApInboxService.ts | 20 ++++++++----------- 1 file changed, 8 insertions(+), 12 deletions(-) diff --git a/packages/backend/src/core/activitypub/ApInboxService.ts b/packages/backend/src/core/activitypub/ApInboxService.ts index cf8172c9fc..95b41626aa 100644 --- a/packages/backend/src/core/activitypub/ApInboxService.ts +++ b/packages/backend/src/core/activitypub/ApInboxService.ts @@ -742,18 +742,14 @@ export class ApInboxService { // fetch the new and old accounts const targetUri = getApHrefNullable(activity.target); if (!targetUri) return 'skip: invalid activity target'; - let newAccount = await this.apPersonService.resolvePerson(targetUri); - let oldAccount = await this.apPersonService.resolvePerson(actor.uri); - - // update them if they're remote - if (newAccount.uri) { - await this.apPersonService.updatePerson(newAccount.uri); - newAccount = await this.apPersonService.resolvePerson(newAccount.uri); - } - if (oldAccount.uri) { - await this.apPersonService.updatePerson(oldAccount.uri); - oldAccount = await this.apPersonService.resolvePerson(oldAccount.uri); - } + await Promise.all([ + this.apPersonService.updatePerson(targetUri), + this.apPersonService.updatePerson(actor.uri), + ]); + const [newAccount, oldAccount] = await Promise.all([ + this.apPersonService.resolvePerson(targetUri), + this.apPersonService.resolvePerson(actor.uri), + ]); // check if alsoKnownAs of the new account is valid let isValidMove = true;