From aa00eb8c6c564447ffd1a0fefc656214bfdb051f Mon Sep 17 00:00:00 2001 From: anatawa12 Date: Fri, 14 Jun 2024 09:26:46 +0900 Subject: [PATCH] Fix replies to me are not included in V[RS]TL if withReplies is disabled (#31) * fix: reply to me is not shown on V[RS]TL * docs(changelog): Fix replies to me are not included in V[RS]TL if withReplies is disabled --- CHANGELOG-VRTL.md | 1 + packages/backend/src/core/FanoutTimelineService.ts | 1 + packages/backend/src/core/NoteCreateService.ts | 3 +++ .../server/api/endpoints/notes/vmimi-relay-hybrid-timeline.ts | 1 + .../src/server/api/endpoints/notes/vmimi-relay-timeline.ts | 1 + 5 files changed, 7 insertions(+) diff --git a/CHANGELOG-VRTL.md b/CHANGELOG-VRTL.md index 6a97758970be..2446537710c3 100644 --- a/CHANGELOG-VRTL.md +++ b/CHANGELOG-VRTL.md @@ -2,4 +2,5 @@ This file lists changes to VRTL Generic Branch. +- Fix replies to me are not included in V\[RS]TL if withReplies is disabled. - Add `vmimiRelayTimelineImplemented` and `disableVmimiRelayTimeline` to nodeinfo diff --git a/packages/backend/src/core/FanoutTimelineService.ts b/packages/backend/src/core/FanoutTimelineService.ts index 4edd4cf2a157..be3c968eeb67 100644 --- a/packages/backend/src/core/FanoutTimelineService.ts +++ b/packages/backend/src/core/FanoutTimelineService.ts @@ -42,6 +42,7 @@ export type FanoutTimelineName = | 'vmimiRelayTimeline' // replies are not included | 'vmimiRelayTimelineWithFiles' // only non-reply notes with files are included | 'vmimiRelayTimelineWithReplies' // only replies are included + | `vmimiRelayTimelineWithReplyTo:${string}` // Only replies to specific local user are included. Parameter is reply user id. @Injectable() export class FanoutTimelineService { diff --git a/packages/backend/src/core/NoteCreateService.ts b/packages/backend/src/core/NoteCreateService.ts index 0e9ddd0d6088..27b66167a382 100644 --- a/packages/backend/src/core/NoteCreateService.ts +++ b/packages/backend/src/core/NoteCreateService.ts @@ -955,6 +955,9 @@ export class NoteCreateService implements OnApplicationShutdown { } if (note.visibility === 'public' && this.vmimiRelayTimelineService.isRelayedInstance(note.userHost)) { this.fanoutTimelineService.push('vmimiRelayTimelineWithReplies', note.id, meta.vmimiRelayTimelineCacheMax, r); + if (note.replyUserHost == null) { + this.fanoutTimelineService.push(`vmimiRelayTimelineWithReplyTo:${note.replyUserId}`, note.id, meta.vmimiRelayTimelineCacheMax / 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/vmimi-relay-hybrid-timeline.ts b/packages/backend/src/server/api/endpoints/notes/vmimi-relay-hybrid-timeline.ts index 027e16a3470f..483bca4d2ecd 100644 --- a/packages/backend/src/server/api/endpoints/notes/vmimi-relay-hybrid-timeline.ts +++ b/packages/backend/src/server/api/endpoints/notes/vmimi-relay-hybrid-timeline.ts @@ -132,6 +132,7 @@ export default class extends Endpoint { // eslint- timelineConfig = [ `homeTimeline:${me.id}`, 'vmimiRelayTimeline', + `vmimiRelayTimelineWithReplyTo:${me.id}`, ]; } diff --git a/packages/backend/src/server/api/endpoints/notes/vmimi-relay-timeline.ts b/packages/backend/src/server/api/endpoints/notes/vmimi-relay-timeline.ts index 032eaf06f714..4dc1e3b78100 100644 --- a/packages/backend/src/server/api/endpoints/notes/vmimi-relay-timeline.ts +++ b/packages/backend/src/server/api/endpoints/notes/vmimi-relay-timeline.ts @@ -119,6 +119,7 @@ export default class extends Endpoint { // eslint- redisTimelines: ps.withFiles ? ['vmimiRelayTimelineWithFiles'] : ps.withReplies ? ['vmimiRelayTimeline', 'vmimiRelayTimelineWithReplies'] + : me ? ['vmimiRelayTimeline', `vmimiRelayTimelineWithReplyTo:${me.id}`] : ['vmimiRelayTimeline'], alwaysIncludeMyNotes: true, excludePureRenotes: !ps.withRenotes,