From f96eae06c401ea09b47b2cd6045572c73b7e6634 Mon Sep 17 00:00:00 2001 From: taichan <40626578+tai-cha@users.noreply.github.com> Date: Thu, 2 Jan 2025 02:09:30 +0000 Subject: [PATCH 1/7] =?UTF-8?q?fix(backend):=20skipHide=E3=81=AA=E3=81=A8?= =?UTF-8?q?=E3=81=8D=E3=81=AB=E3=82=82=E3=83=AD=E3=83=83=E3=82=AF=E3=83=80?= =?UTF-8?q?=E3=82=A6=E3=83=B3=E3=81=95=E3=82=8C=E3=81=9F=E3=83=8E=E3=83=BC?= =?UTF-8?q?=E3=83=88=E3=81=AEprivate=E5=8C=96=E3=82=92=E3=81=99=E3=82=8B?= =?UTF-8?q?=E3=82=88=E3=81=86=E3=81=AB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../backend/src/core/entities/NoteEntityService.ts | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/packages/backend/src/core/entities/NoteEntityService.ts b/packages/backend/src/core/entities/NoteEntityService.ts index 96cc6b028ec0..8508fe7cb8e0 100644 --- a/packages/backend/src/core/entities/NoteEntityService.ts +++ b/packages/backend/src/core/entities/NoteEntityService.ts @@ -102,8 +102,7 @@ export class NoteEntityService implements OnModuleInit { } @bindThis - private async hideNote(packedNote: Packed<'Note'>, meId: MiUser['id'] | null): Promise { - // FIXME: このvisibility変更処理が当関数にあるのは若干不自然かもしれない(関数名を treatVisibility とかに変える手もある) + private async treatVisibility(packedNote: Packed<'Note'>): Promise { if (packedNote.visibility === 'public' || packedNote.visibility === 'home') { const followersOnlyBefore = packedNote.user.makeNotesFollowersOnlyBefore; if ((followersOnlyBefore != null) @@ -115,7 +114,10 @@ export class NoteEntityService implements OnModuleInit { packedNote.visibility = 'followers'; } } + } + @bindThis + private async hideNote(packedNote: Packed<'Note'>, meId: MiUser['id'] | null): Promise { if (meId === packedNote.userId) return; // TODO: isVisibleForMe を使うようにしても良さそう(型違うけど) @@ -359,6 +361,7 @@ export class NoteEntityService implements OnModuleInit { const opts = Object.assign({ detail: true, skipHide: false, + skipTreatVisibility: false, withReactionAndUserPairCache: false, }, options); @@ -458,6 +461,10 @@ export class NoteEntityService implements OnModuleInit { } : {}), }); + if (!opts.skipTreatVisibility) { + await this.treatVisibility(packed, meId); + } + if (!opts.skipHide) { await this.hideNote(packed, meId); } From df789cec00667a1c551a0d6fce5e9895226637db Mon Sep 17 00:00:00 2001 From: taichan <40626578+tai-cha@users.noreply.github.com> Date: Thu, 2 Jan 2025 02:24:50 +0000 Subject: [PATCH 2/7] fix linting --- packages/backend/src/core/entities/NoteEntityService.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/backend/src/core/entities/NoteEntityService.ts b/packages/backend/src/core/entities/NoteEntityService.ts index 8508fe7cb8e0..c55a8dc44378 100644 --- a/packages/backend/src/core/entities/NoteEntityService.ts +++ b/packages/backend/src/core/entities/NoteEntityService.ts @@ -462,7 +462,7 @@ export class NoteEntityService implements OnModuleInit { }); if (!opts.skipTreatVisibility) { - await this.treatVisibility(packed, meId); + await this.treatVisibility(packed); } if (!opts.skipHide) { From 28dea231e684b9c57bf815367a0bbfd194be1a56 Mon Sep 17 00:00:00 2001 From: taichan <40626578+tai-cha@users.noreply.github.com> Date: Sun, 5 Jan 2025 08:22:25 +0900 Subject: [PATCH 3/7] Update packages/backend/src/core/entities/NoteEntityService.ts --- packages/backend/src/core/entities/NoteEntityService.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/backend/src/core/entities/NoteEntityService.ts b/packages/backend/src/core/entities/NoteEntityService.ts index c55a8dc44378..8d00d65211c0 100644 --- a/packages/backend/src/core/entities/NoteEntityService.ts +++ b/packages/backend/src/core/entities/NoteEntityService.ts @@ -102,7 +102,7 @@ export class NoteEntityService implements OnModuleInit { } @bindThis - private async treatVisibility(packedNote: Packed<'Note'>): Promise { + private treatVisibility(packedNote: Packed<'Note'>): Promise { if (packedNote.visibility === 'public' || packedNote.visibility === 'home') { const followersOnlyBefore = packedNote.user.makeNotesFollowersOnlyBefore; if ((followersOnlyBefore != null) From 09d8297fc9d9c2260906d9570698a6105c6e36a5 Mon Sep 17 00:00:00 2001 From: tai-cha Date: Sun, 5 Jan 2025 12:16:52 +0900 Subject: [PATCH 4/7] Fix: type error --- packages/backend/src/core/entities/NoteEntityService.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/packages/backend/src/core/entities/NoteEntityService.ts b/packages/backend/src/core/entities/NoteEntityService.ts index 8d00d65211c0..97ec9981a4c8 100644 --- a/packages/backend/src/core/entities/NoteEntityService.ts +++ b/packages/backend/src/core/entities/NoteEntityService.ts @@ -102,7 +102,7 @@ export class NoteEntityService implements OnModuleInit { } @bindThis - private treatVisibility(packedNote: Packed<'Note'>): Promise { + private treatVisibility(packedNote: Packed<'Note'>): Packed<'Note'>['visibility'] { if (packedNote.visibility === 'public' || packedNote.visibility === 'home') { const followersOnlyBefore = packedNote.user.makeNotesFollowersOnlyBefore; if ((followersOnlyBefore != null) @@ -114,6 +114,7 @@ export class NoteEntityService implements OnModuleInit { packedNote.visibility = 'followers'; } } + return packedNote.visibility; } @bindThis From cccc18041b08c968418f4bca14b6f16b9cfa34cf Mon Sep 17 00:00:00 2001 From: tai-cha Date: Sun, 5 Jan 2025 12:18:03 +0900 Subject: [PATCH 5/7] Remove unneeded await --- packages/backend/src/core/entities/NoteEntityService.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/backend/src/core/entities/NoteEntityService.ts b/packages/backend/src/core/entities/NoteEntityService.ts index 97ec9981a4c8..07334242669d 100644 --- a/packages/backend/src/core/entities/NoteEntityService.ts +++ b/packages/backend/src/core/entities/NoteEntityService.ts @@ -463,7 +463,7 @@ export class NoteEntityService implements OnModuleInit { }); if (!opts.skipTreatVisibility) { - await this.treatVisibility(packed); + his.treatVisibility(packed); } if (!opts.skipHide) { From 05967333c8386338f1eddd3f4a64727d35e1d71c Mon Sep 17 00:00:00 2001 From: tai-cha Date: Sun, 5 Jan 2025 12:18:17 +0900 Subject: [PATCH 6/7] Fix: typo --- packages/backend/src/core/entities/NoteEntityService.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/backend/src/core/entities/NoteEntityService.ts b/packages/backend/src/core/entities/NoteEntityService.ts index 07334242669d..8585bf44c8e1 100644 --- a/packages/backend/src/core/entities/NoteEntityService.ts +++ b/packages/backend/src/core/entities/NoteEntityService.ts @@ -463,7 +463,7 @@ export class NoteEntityService implements OnModuleInit { }); if (!opts.skipTreatVisibility) { - his.treatVisibility(packed); + this.treatVisibility(packed); } if (!opts.skipHide) { From d9df46d5de8d9a55e00f2ec4d83b6702a01ad682 Mon Sep 17 00:00:00 2001 From: tai-cha Date: Tue, 7 Jan 2025 21:32:59 +0900 Subject: [PATCH 7/7] Remove skipTreatVisibillity --- packages/backend/src/core/entities/NoteEntityService.ts | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/packages/backend/src/core/entities/NoteEntityService.ts b/packages/backend/src/core/entities/NoteEntityService.ts index 8585bf44c8e1..97f1c3d739e3 100644 --- a/packages/backend/src/core/entities/NoteEntityService.ts +++ b/packages/backend/src/core/entities/NoteEntityService.ts @@ -362,7 +362,6 @@ export class NoteEntityService implements OnModuleInit { const opts = Object.assign({ detail: true, skipHide: false, - skipTreatVisibility: false, withReactionAndUserPairCache: false, }, options); @@ -462,9 +461,7 @@ export class NoteEntityService implements OnModuleInit { } : {}), }); - if (!opts.skipTreatVisibility) { - this.treatVisibility(packed); - } + this.treatVisibility(packed); if (!opts.skipHide) { await this.hideNote(packed, meId);