From af30959cb95e295b2b97c2ab8630398ef55e5932 Mon Sep 17 00:00:00 2001 From: syuilo Date: Thu, 13 Jul 2023 20:15:47 +0900 Subject: [PATCH] fix runtime error --- .../activitypub/ApDeliverManagerService.ts | 134 +++++++++--------- 1 file changed, 67 insertions(+), 67 deletions(-) diff --git a/packages/backend/src/core/activitypub/ApDeliverManagerService.ts b/packages/backend/src/core/activitypub/ApDeliverManagerService.ts index ae1e42bf53..09461973d9 100644 --- a/packages/backend/src/core/activitypub/ApDeliverManagerService.ts +++ b/packages/backend/src/core/activitypub/ApDeliverManagerService.ts @@ -29,73 +29,6 @@ const isFollowers = (recipe: IRecipe): recipe is IFollowersRecipe => const isDirect = (recipe: IRecipe): recipe is IDirectRecipe => recipe.type === 'Direct'; -@Injectable() -export class ApDeliverManagerService { - constructor( - @Inject(DI.config) - private config: Config, - - @Inject(DI.usersRepository) - private usersRepository: UsersRepository, - - @Inject(DI.followingsRepository) - private followingsRepository: FollowingsRepository, - - private userEntityService: UserEntityService, - private queueService: QueueService, - ) { - } - - /** - * Deliver activity to followers - * @param actor - * @param activity Activity - */ - @bindThis - public async deliverToFollowers(actor: { id: LocalUser['id']; host: null; }, activity: IActivity): Promise { - const manager = new DeliverManager( - this.userEntityService, - this.followingsRepository, - this.queueService, - actor, - activity, - ); - manager.addFollowersRecipe(); - await manager.execute(); - } - - /** - * Deliver activity to user - * @param actor - * @param activity Activity - * @param to Target user - */ - @bindThis - public async deliverToUser(actor: { id: LocalUser['id']; host: null; }, activity: IActivity, to: RemoteUser): Promise { - const manager = new DeliverManager( - this.userEntityService, - this.followingsRepository, - this.queueService, - actor, - activity, - ); - manager.addDirectRecipe(to); - await manager.execute(); - } - - @bindThis - public createDeliverManager(actor: { id: User['id']; host: null; }, activity: IActivity | null): DeliverManager { - return new DeliverManager( - this.userEntityService, - this.followingsRepository, - this.queueService, - - actor, - activity, - ); - } -} - class DeliverManager { private actor: ThinUser; private activity: IActivity | null; @@ -210,3 +143,70 @@ class DeliverManager { this.queueService.deliverMany(this.actor, this.activity, inboxes); } } + +@Injectable() +export class ApDeliverManagerService { + constructor( + @Inject(DI.config) + private config: Config, + + @Inject(DI.usersRepository) + private usersRepository: UsersRepository, + + @Inject(DI.followingsRepository) + private followingsRepository: FollowingsRepository, + + private userEntityService: UserEntityService, + private queueService: QueueService, + ) { + } + + /** + * Deliver activity to followers + * @param actor + * @param activity Activity + */ + @bindThis + public async deliverToFollowers(actor: { id: LocalUser['id']; host: null; }, activity: IActivity): Promise { + const manager = new DeliverManager( + this.userEntityService, + this.followingsRepository, + this.queueService, + actor, + activity, + ); + manager.addFollowersRecipe(); + await manager.execute(); + } + + /** + * Deliver activity to user + * @param actor + * @param activity Activity + * @param to Target user + */ + @bindThis + public async deliverToUser(actor: { id: LocalUser['id']; host: null; }, activity: IActivity, to: RemoteUser): Promise { + const manager = new DeliverManager( + this.userEntityService, + this.followingsRepository, + this.queueService, + actor, + activity, + ); + manager.addDirectRecipe(to); + await manager.execute(); + } + + @bindThis + public createDeliverManager(actor: { id: User['id']; host: null; }, activity: IActivity | null): DeliverManager { + return new DeliverManager( + this.userEntityService, + this.followingsRepository, + this.queueService, + + actor, + activity, + ); + } +}