From 8f94b367322f805bdc91354510cdc3c82e438dca Mon Sep 17 00:00:00 2001 From: "Umisyo(Souta Kusunoki)" <44742896+Umisyo@users.noreply.github.com> Date: Wed, 5 Jul 2023 12:17:52 +0900 Subject: [PATCH] =?UTF-8?q?refactor:=20ApDeliverManagerService.ts=E3=81=AE?= =?UTF-8?q?=E5=9E=8B=E3=81=A8JSDoc=E3=82=92=E9=81=A9=E5=88=87=E3=81=AB?= =?UTF-8?q?=E7=BD=AE=E3=81=8D=E6=8F=9B=E3=81=88=20(#11096)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * refactor: ApDeliverManagerService.ts のanyを適切な型に置き換え Signed-off-by: Umisyo * fix: quote to single quote Signed-off-by: Umisyo * refactor: JSDocを実態に合わせて修正 Signed-off-by: Umisyo * fix: activityのnullを許容するよう変更 Signed-off-by: Umisyo --------- Signed-off-by: Umisyo Co-authored-by: tamaina --- .../activitypub/ApDeliverManagerService.ts | 21 ++++++++++++------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/packages/backend/src/core/activitypub/ApDeliverManagerService.ts b/packages/backend/src/core/activitypub/ApDeliverManagerService.ts index 66e7761187..6e910eb538 100644 --- a/packages/backend/src/core/activitypub/ApDeliverManagerService.ts +++ b/packages/backend/src/core/activitypub/ApDeliverManagerService.ts @@ -7,6 +7,7 @@ import type { LocalUser, RemoteUser, User } from '@/models/entities/User.js'; import { QueueService } from '@/core/QueueService.js'; import { UserEntityService } from '@/core/entities/UserEntityService.js'; import { bindThis } from '@/decorators.js'; +import type { IActivity } from '@/core/activitypub/type.js'; import { ThinUser } from '@/queue/types.js'; interface IRecipe { @@ -22,10 +23,10 @@ interface IDirectRecipe extends IRecipe { to: RemoteUser; } -const isFollowers = (recipe: any): recipe is IFollowersRecipe => +const isFollowers = (recipe: IRecipe): recipe is IFollowersRecipe => recipe.type === 'Followers'; -const isDirect = (recipe: any): recipe is IDirectRecipe => +const isDirect = (recipe: IRecipe): recipe is IDirectRecipe => recipe.type === 'Direct'; @Injectable() @@ -47,11 +48,11 @@ export class ApDeliverManagerService { /** * Deliver activity to followers + * @param actor * @param activity Activity - * @param from Followee */ @bindThis - public async deliverToFollowers(actor: { id: LocalUser['id']; host: null; }, activity: any) { + public async deliverToFollowers(actor: { id: LocalUser['id']; host: null; }, activity: IActivity) { const manager = new DeliverManager( this.userEntityService, this.followingsRepository, @@ -65,11 +66,12 @@ export class ApDeliverManagerService { /** * Deliver activity to user + * @param actor * @param activity Activity * @param to Target user */ @bindThis - public async deliverToUser(actor: { id: LocalUser['id']; host: null; }, activity: any, to: RemoteUser) { + public async deliverToUser(actor: { id: LocalUser['id']; host: null; }, activity: IActivity, to: RemoteUser) { const manager = new DeliverManager( this.userEntityService, this.followingsRepository, @@ -82,7 +84,7 @@ export class ApDeliverManagerService { } @bindThis - public createDeliverManager(actor: { id: User['id']; host: null; }, activity: any) { + public createDeliverManager(actor: { id: User['id']; host: null; }, activity: IActivity | null) { return new DeliverManager( this.userEntityService, this.followingsRepository, @@ -96,11 +98,14 @@ export class ApDeliverManagerService { class DeliverManager { private actor: ThinUser; - private activity: any; + private activity: IActivity | null; private recipes: IRecipe[] = []; /** * Constructor + * @param userEntityService + * @param followingsRepository + * @param queueService * @param actor Actor * @param activity Activity to deliver */ @@ -110,7 +115,7 @@ class DeliverManager { private queueService: QueueService, actor: { id: User['id']; host: null; }, - activity: any, + activity: IActivity | null, ) { // 型で弾いてはいるが一応ローカルユーザーかチェック if (actor.host != null) throw new Error('actor.host must be null');