From 0082f6f8e8c5d5febd14933ba9a1ac643f70ca92 Mon Sep 17 00:00:00 2001 From: tamaina Date: Tue, 5 Mar 2024 05:15:56 +0000 Subject: [PATCH] fix? --- packages/backend/src/core/AccountUpdateService.ts | 2 ++ packages/backend/src/core/UserKeypairService.ts | 5 +++++ .../src/core/activitypub/ApDeliverManagerService.ts | 8 -------- 3 files changed, 7 insertions(+), 8 deletions(-) diff --git a/packages/backend/src/core/AccountUpdateService.ts b/packages/backend/src/core/AccountUpdateService.ts index fd790913b4..5102d0508d 100644 --- a/packages/backend/src/core/AccountUpdateService.ts +++ b/packages/backend/src/core/AccountUpdateService.ts @@ -30,6 +30,8 @@ export class AccountUpdateService implements OnModuleInit { } async onModuleInit() { + // Circular dependency + // AccountUpdateService - ApDeliverManagerSevice( - DeliverManager) - UserKeypairService - AccountUpdateService this.apDeliverManagerService = this.moduleRef.get(ApDeliverManagerService.name); } diff --git a/packages/backend/src/core/UserKeypairService.ts b/packages/backend/src/core/UserKeypairService.ts index c27f8fc71a..34199a68f4 100644 --- a/packages/backend/src/core/UserKeypairService.ts +++ b/packages/backend/src/core/UserKeypairService.ts @@ -13,6 +13,7 @@ import type { MiUserKeypair } from '@/models/UserKeypair.js'; import { DI } from '@/di-symbols.js'; import { bindThis } from '@/decorators.js'; import { GlobalEventService, GlobalEvents } from '@/core/GlobalEventService.js'; +import { AccountUpdateService } from '@/core/AccountUpdateService.js'; @Injectable() export class UserKeypairService implements OnApplicationShutdown { @@ -27,6 +28,7 @@ export class UserKeypairService implements OnApplicationShutdown { private userKeypairsRepository: UserKeypairsRepository, private globalEventService: GlobalEventService, + private accountUpdateService: AccountUpdateService, ) { this.cache = new RedisKVCache(this.redisClient, 'userKeypair', { lifetime: 1000 * 60 * 60 * 24, // 24h @@ -54,12 +56,15 @@ export class UserKeypairService implements OnApplicationShutdown { await this.refresh(userId); const keypair = await this.cache.fetch(userId); if (keypair.ed25519PublicKey != null) return; + const ed25519 = await genEd25519KeyPair(); await this.userKeypairsRepository.update({ userId }, { ed25519PublicKey: ed25519.publicKey, ed25519PrivateKey: ed25519.privateKey, }); this.globalEventService.publishInternalEvent('userKeypairUpdated', { userId }); + // リモートに配信 + await this.accountUpdateService.publishToFollowers(userId, true); } @bindThis diff --git a/packages/backend/src/core/activitypub/ApDeliverManagerService.ts b/packages/backend/src/core/activitypub/ApDeliverManagerService.ts index cf3dce465e..1ba6416ad4 100644 --- a/packages/backend/src/core/activitypub/ApDeliverManagerService.ts +++ b/packages/backend/src/core/activitypub/ApDeliverManagerService.ts @@ -13,7 +13,6 @@ import { bindThis } from '@/decorators.js'; import type { IActivity } from '@/core/activitypub/type.js'; import { ThinUser } from '@/queue/types.js'; import { UserKeypairService } from '../UserKeypairService.js'; -import { AccountUpdateService } from '@/core/AccountUpdateService.js'; interface IRecipe { type: string; @@ -51,7 +50,6 @@ class DeliverManager { private userKeypairService: UserKeypairService, private followingsRepository: FollowingsRepository, private queueService: QueueService, - private accountUpdateService: AccountUpdateService, actor: { id: MiUser['id']; host: null; }, activity: IActivity | null, @@ -113,8 +111,6 @@ class DeliverManager { * ed25519の署名がなければ追加する */ await this.userKeypairService.refreshAndprepareEd25519KeyPair(this.actor.id); - // リモートに配信 - await this.accountUpdateService.publishToFollowers(this.actor.id, true); } //#endregion @@ -169,7 +165,6 @@ export class ApDeliverManagerService { private userKeypairService: UserKeypairService, private queueService: QueueService, - private accountUpdateService: AccountUpdateService, ) { } @@ -185,7 +180,6 @@ export class ApDeliverManagerService { this.userKeypairService, this.followingsRepository, this.queueService, - this.accountUpdateService, actor, activity, ); @@ -205,7 +199,6 @@ export class ApDeliverManagerService { this.userKeypairService, this.followingsRepository, this.queueService, - this.accountUpdateService, actor, activity, ); @@ -219,7 +212,6 @@ export class ApDeliverManagerService { this.userKeypairService, this.followingsRepository, this.queueService, - this.accountUpdateService, actor, activity, );