From 8795d6f254bd8f88c385bf77b82cc6f177c94df9 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Fri, 26 Feb 2021 14:22:25 +0100 Subject: Fix broken local actors Some channels can't federate because they don't have public/private keys, maybe because the generation failed for various reasons --- server/lib/activitypub/actor.ts | 20 ++++++++------------ 1 file changed, 8 insertions(+), 12 deletions(-) (limited to 'server/lib/activitypub/actor.ts') diff --git a/server/lib/activitypub/actor.ts b/server/lib/activitypub/actor.ts index dbb243d3a..a726f9e20 100644 --- a/server/lib/activitypub/actor.ts +++ b/server/lib/activitypub/actor.ts @@ -39,17 +39,13 @@ import { getServerActor } from '@server/models/application/application' import { HttpStatusCode } from '../../../shared/core-utils/miscs/http-error-codes' // Set account keys, this could be long so process after the account creation and do not block the client -function setAsyncActorKeys (actor: T) { - return createPrivateAndPublicKeys() - .then(({ publicKey, privateKey }) => { - actor.publicKey = publicKey - actor.privateKey = privateKey - return actor.save() - }) - .catch(err => { - logger.error('Cannot set public/private keys of actor %d.', actor.url, { err }) - return actor - }) +async function generateAndSaveActorKeys (actor: T) { + const { publicKey, privateKey } = await createPrivateAndPublicKeys() + + actor.publicKey = publicKey + actor.privateKey = privateKey + + return actor.save() } function getOrCreateActorAndServerAndModel ( @@ -346,7 +342,7 @@ async function refreshActorIfNeeded