From e2b574a97c3e9f717fd0b71a5f16f7bf92271381 Mon Sep 17 00:00:00 2001 From: tamaina Date: Sun, 10 Mar 2024 16:00:25 +0000 Subject: [PATCH] save array --- .../src/core/activitypub/models/ApPersonService.ts | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/packages/backend/src/core/activitypub/models/ApPersonService.ts b/packages/backend/src/core/activitypub/models/ApPersonService.ts index a977c9251d..814c4646b6 100644 --- a/packages/backend/src/core/activitypub/models/ApPersonService.ts +++ b/packages/backend/src/core/activitypub/models/ApPersonService.ts @@ -396,18 +396,16 @@ export class ApPersonService implements OnModuleInit { })); if (person.publicKey) { - const keys = new Map([ + const publicKeys = new Map([ ...(person.additionalPublicKeys ? person.additionalPublicKeys.map(key => [key.id, key] as const) : []), [person.publicKey.id, person.publicKey], ]); - for (const key of keys.values()) { - await transactionalEntityManager.save(new MiUserPublickey({ - keyId: key.id, - userId: user.id, - keyPem: key.publicKeyPem, - })); - } + await this.userPublickeysRepository.save(Array.from(publicKeys.values(), key => ({ + keyId: key.id, + userId: user!.id, + keyPem: key.publicKeyPem, + }))); } }); } catch (e) {