aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/lib/activitypub/actor.ts
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2021-02-26 14:22:25 +0100
committerChocobozzz <me@florianbigard.com>2021-02-26 14:22:25 +0100
commit8795d6f254bd8f88c385bf77b82cc6f177c94df9 (patch)
tree88f8f4fced9e0c12db5b43dcac6e44bd94eb8b1a /server/lib/activitypub/actor.ts
parent92315d979c3f424d81f8fca3c8831d81e4e2a6d6 (diff)
downloadPeerTube-8795d6f254bd8f88c385bf77b82cc6f177c94df9.tar.gz
PeerTube-8795d6f254bd8f88c385bf77b82cc6f177c94df9.tar.zst
PeerTube-8795d6f254bd8f88c385bf77b82cc6f177c94df9.zip
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
Diffstat (limited to 'server/lib/activitypub/actor.ts')
-rw-r--r--server/lib/activitypub/actor.ts20
1 files changed, 8 insertions, 12 deletions
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'
39import { HttpStatusCode } from '../../../shared/core-utils/miscs/http-error-codes' 39import { HttpStatusCode } from '../../../shared/core-utils/miscs/http-error-codes'
40 40
41// Set account keys, this could be long so process after the account creation and do not block the client 41// Set account keys, this could be long so process after the account creation and do not block the client
42function setAsyncActorKeys <T extends MActor> (actor: T) { 42async function generateAndSaveActorKeys <T extends MActor> (actor: T) {
43 return createPrivateAndPublicKeys() 43 const { publicKey, privateKey } = await createPrivateAndPublicKeys()
44 .then(({ publicKey, privateKey }) => { 44
45 actor.publicKey = publicKey 45 actor.publicKey = publicKey
46 actor.privateKey = privateKey 46 actor.privateKey = privateKey
47 return actor.save() 47
48 }) 48 return actor.save()
49 .catch(err => {
50 logger.error('Cannot set public/private keys of actor %d.', actor.url, { err })
51 return actor
52 })
53} 49}
54 50
55function getOrCreateActorAndServerAndModel ( 51function getOrCreateActorAndServerAndModel (
@@ -346,7 +342,7 @@ async function refreshActorIfNeeded <T extends MActorFull | MActorAccountChannel
346export { 342export {
347 getOrCreateActorAndServerAndModel, 343 getOrCreateActorAndServerAndModel,
348 buildActorInstance, 344 buildActorInstance,
349 setAsyncActorKeys, 345 generateAndSaveActorKeys,
350 fetchActorTotalItems, 346 fetchActorTotalItems,
351 getAvatarInfoIfExists, 347 getAvatarInfoIfExists,
352 updateActorInstance, 348 updateActorInstance,