From bb38e62ae696873990d0252c66200c361878e9f8 Mon Sep 17 00:00:00 2001 From: anatawa12 Date: Mon, 4 Dec 2023 17:56:48 +0900 Subject: [PATCH] =?UTF-8?q?chore:=20=E8=87=AA=E5=88=86=E3=81=B8=E3=81=AE?= =?UTF-8?q?=E3=83=AA=E3=83=97=E3=83=A9=E3=82=A4=E3=81=AE=E3=81=BF=E8=B5=B0?= =?UTF-8?q?=E6=9F=BB=E3=81=99=E3=82=8B=E3=82=88=E3=81=86=E3=81=AB=20(#1257?= =?UTF-8?q?0)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packages/backend/src/core/FanoutTimelineService.ts | 1 + packages/backend/src/core/NoteCreateService.ts | 3 +++ .../src/server/api/endpoints/notes/local-timeline.ts | 9 ++++++--- 3 files changed, 10 insertions(+), 3 deletions(-) diff --git a/packages/backend/src/core/FanoutTimelineService.ts b/packages/backend/src/core/FanoutTimelineService.ts index 654a035a5f..9b2678fbcd 100644 --- a/packages/backend/src/core/FanoutTimelineService.ts +++ b/packages/backend/src/core/FanoutTimelineService.ts @@ -17,6 +17,7 @@ export type FanoutTimelineName = | `localTimeline` // replies are not included | `localTimelineWithFiles` // only non-reply notes with files are included | `localTimelineWithReplies` // only replies are included + | `localTimelineWithReplyTo:${string}` // Only replies to specific local user are included. Parameter is reply user id. // antenna | `antennaTimeline:${string}` diff --git a/packages/backend/src/core/NoteCreateService.ts b/packages/backend/src/core/NoteCreateService.ts index 0110ebaf5e..45dfbb87aa 100644 --- a/packages/backend/src/core/NoteCreateService.ts +++ b/packages/backend/src/core/NoteCreateService.ts @@ -933,6 +933,9 @@ export class NoteCreateService implements OnApplicationShutdown { if (note.visibility === 'public' && note.userHost == null) { this.fanoutTimelineService.push('localTimelineWithReplies', note.id, 300, r); + if (note.replyUserHost == null) { + this.fanoutTimelineService.push(`localTimelineWithReplyTo:${note.replyUserId}`, note.id, 300 / 10, r); + } } } else { this.fanoutTimelineService.push(`userTimeline:${user.id}`, note.id, note.userHost == null ? meta.perLocalUserUserTimelineCacheMax : meta.perRemoteUserUserTimelineCacheMax, r); 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 e8ba39bbf0..3fd4dc83fb 100644 --- a/packages/backend/src/server/api/endpoints/notes/local-timeline.ts +++ b/packages/backend/src/server/api/endpoints/notes/local-timeline.ts @@ -42,7 +42,7 @@ export const meta = { bothWithRepliesAndWithFiles: { message: 'Specifying both withReplies and withFiles is not supported', code: 'BOTH_WITH_REPLIES_AND_WITH_FILES', - id: 'dd9c8400-1cb5-4eef-8a31-200c5f933793' + id: 'dd9c8400-1cb5-4eef-8a31-200c5f933793', }, }, } as const; @@ -116,9 +116,12 @@ export default class extends Endpoint { // eslint- allowPartial: ps.allowPartial, me, useDbFallback: serverSettings.enableFanoutTimelineDbFallback, - redisTimelines: ps.withFiles ? ['localTimelineWithFiles'] : ['localTimeline', 'localTimelineWithReplies'], + redisTimelines: + ps.withFiles ? ['localTimelineWithFiles'] + : ps.withReplies ? ['localTimeline', 'localTimelineWithReplies'] + : me ? ['localTimeline', `localTimelineWithReplyTo:${me.id}`] + : ['localTimeline'], alwaysIncludeMyNotes: true, - excludeReplies: !ps.withReplies, excludePureRenotes: !ps.withRenotes, dbFallback: async (untilId, sinceId, limit) => await this.getFromDb({ untilId,