From a26d9ea132f3a8a48109083f014abc377614d719 Mon Sep 17 00:00:00 2001 From: syuilo Date: Wed, 11 Oct 2023 17:29:24 +0900 Subject: [PATCH] =?UTF-8?q?enhance(backend):=20LTL=E3=81=A7=E3=83=95?= =?UTF-8?q?=E3=82=A9=E3=83=AD=E3=83=BC=E3=81=97=E3=81=A6=E3=81=84=E3=82=8B?= =?UTF-8?q?=E3=83=A6=E3=83=BC=E3=82=B6=E3=83=BC=E3=81=8B=E3=82=89=E3=81=AE?= =?UTF-8?q?=E8=87=AA=E5=88=86=E3=81=B8=E3=81=AE=E8=BF=94=E4=BF=A1=E3=81=8C?= =?UTF-8?q?=E5=90=AB=E3=81=BE=E3=82=8C=E3=82=8B=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/server/api/endpoints/notes/local-timeline.ts | 5 ++--- packages/backend/test/e2e/timelines.ts | 5 +---- 2 files changed, 3 insertions(+), 7 deletions(-) diff --git a/packages/backend/src/server/api/endpoints/notes/local-timeline.ts b/packages/backend/src/server/api/endpoints/notes/local-timeline.ts index 55b5d47386..d10c3bedbf 100644 --- a/packages/backend/src/server/api/endpoints/notes/local-timeline.ts +++ b/packages/backend/src/server/api/endpoints/notes/local-timeline.ts @@ -95,15 +95,13 @@ export default class extends Endpoint { // eslint- if (ps.withFiles) { noteIds = await this.redisTimelineService.get('localTimelineWithFiles', untilId, sinceId); - } else if (ps.withReplies) { + } else { const [nonReplyNoteIds, replyNoteIds] = await this.redisTimelineService.getMulti([ 'localTimeline', 'localTimelineWithReplies', ], untilId, sinceId); noteIds = Array.from(new Set([...nonReplyNoteIds, ...replyNoteIds])); noteIds.sort((a, b) => a > b ? -1 : 1); - } else { - noteIds = await this.redisTimelineService.get('localTimeline', untilId, sinceId); } noteIds = noteIds.slice(0, ps.limit); @@ -127,6 +125,7 @@ export default class extends Endpoint { // eslint- if (me && (note.userId === me.id)) { return true; } + if (!ps.withReplies && note.replyId && (me == null || note.replyUserId !== me.id)) return false; if (me && isUserRelated(note, userIdsWhoBlockingMe)) return false; if (me && isUserRelated(note, userIdsWhoMeMuting)) return false; if (note.renoteId) { diff --git a/packages/backend/test/e2e/timelines.ts b/packages/backend/test/e2e/timelines.ts index ce92a36cf9..cd27b094ea 100644 --- a/packages/backend/test/e2e/timelines.ts +++ b/packages/backend/test/e2e/timelines.ts @@ -19,7 +19,7 @@ function genHost() { } function waitForPushToTl() { - return sleep(300); + return sleep(500); } let app: INestApplicationContext; @@ -619,7 +619,6 @@ describe('Timelines', () => { assert.strictEqual(res.body.some((note: any) => note.id === carolNote.id), false); }); - /* 実装が面倒 test.concurrent('withReplies: false でフォローしているユーザーからの自分への返信が含まれる', async () => { const [alice, bob] = await Promise.all([signup(), signup()]); @@ -635,7 +634,6 @@ describe('Timelines', () => { assert.strictEqual(res.body.some((note: any) => note.id === aliceNote.id), true); assert.strictEqual(res.body.some((note: any) => note.id === bobNote.id), true); }); - */ test.concurrent('[withReplies: true] 他人の他人への返信が含まれる', async () => { const [alice, bob, carol] = await Promise.all([signup(), signup(), signup()]); @@ -786,7 +784,6 @@ describe('Timelines', () => { const res = await api('/notes/hybrid-timeline', { withReplies: true }, alice); assert.strictEqual(res.body.some((note: any) => note.id === bobNote.id), true); - assert.strictEqual(res.body.some((note: any) => note.id === carolNote.id), true); }); test.concurrent('[withFiles: true] ファイル付きノートのみ含まれる', async () => {