From dc9a839626a0e79e8edae806939480be343338e5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=BE=E3=81=A3=E3=81=A1=E3=82=83=E3=81=A8=E3=83=BC?= =?UTF-8?q?=E3=81=AB=E3=82=85?= <17376330+u1-liquid@users.noreply.github.com> Date: Mon, 29 Apr 2024 07:23:34 +0900 Subject: [PATCH] =?UTF-8?q?fix(backend):=20=E3=83=AA=E3=83=8E=E3=83=BC?= =?UTF-8?q?=E3=83=88=E3=81=AE=E8=A9=95=E4=BE=A1=E3=81=AE=E9=A0=86=E7=95=AA?= =?UTF-8?q?=E3=82=92=E5=A4=89=E6=9B=B4=E3=80=81isQuote=E3=83=BBisQuotePack?= =?UTF-8?q?ed=E3=81=AE=E6=8C=99=E5=8B=95=E3=82=92=E4=BF=AE=E6=AD=A3=20(Mis?= =?UTF-8?q?skeyIO#622)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packages/backend/src/core/NoteCreateService.ts | 2 +- packages/backend/src/misc/is-renote.ts | 12 ++++++++---- .../server/api/stream/channels/global-timeline.ts | 2 +- .../src/server/api/stream/channels/home-timeline.ts | 2 +- .../server/api/stream/channels/hybrid-timeline.ts | 2 +- .../src/server/api/stream/channels/local-timeline.ts | 2 +- .../src/server/api/stream/channels/role-timeline.ts | 2 +- .../src/server/api/stream/channels/user-list.ts | 2 +- 8 files changed, 15 insertions(+), 11 deletions(-) diff --git a/packages/backend/src/core/NoteCreateService.ts b/packages/backend/src/core/NoteCreateService.ts index b57e8853c..d07e3fdf9 100644 --- a/packages/backend/src/core/NoteCreateService.ts +++ b/packages/backend/src/core/NoteCreateService.ts @@ -791,7 +791,7 @@ export class NoteCreateService implements OnApplicationShutdown { private isQuote(note: Option): note is Option & { renote: MiNote } & ( { text: string } | { cw: string } | { reply: MiNote } | { poll: IPoll } | { files: MiDriveFile[] } ) { - // NOTE: SYNC WITH misc/is-quote.ts + // NOTE: SYNC WITH misc/is-renote.ts return note.renote != null && ( note.text != null || note.reply != null || diff --git a/packages/backend/src/misc/is-renote.ts b/packages/backend/src/misc/is-renote.ts index 48f821806..9a4a4d79a 100644 --- a/packages/backend/src/misc/is-renote.ts +++ b/packages/backend/src/misc/is-renote.ts @@ -29,11 +29,13 @@ export function isRenote(note: MiNote): note is Renote { export function isQuote(note: Renote): note is Quote { // NOTE: SYNC WITH NoteCreateService.isQuote - return note.text != null || + return note.renoteId != null && ( + note.text != null || note.cw != null || note.replyId != null || note.hasPoll || - note.fileIds.length > 0; + note.fileIds.length > 0 + ); } type PackedRenote = @@ -59,9 +61,11 @@ export function isRenotePacked(note: Packed<'Note'>): note is PackedRenote { } export function isQuotePacked(note: PackedRenote): note is PackedQuote { - return note.text != null || + return note.renoteId != null && ( + note.text != null || note.cw != null || note.replyId != null || note.poll != null || - (note.fileIds != null && note.fileIds.length > 0); + (note.fileIds != null && note.fileIds.length > 0) + ); } diff --git a/packages/backend/src/server/api/stream/channels/global-timeline.ts b/packages/backend/src/server/api/stream/channels/global-timeline.ts index c3840e88b..fee5972e8 100644 --- a/packages/backend/src/server/api/stream/channels/global-timeline.ts +++ b/packages/backend/src/server/api/stream/channels/global-timeline.ts @@ -67,7 +67,7 @@ class GlobalTimelineChannel extends Channel { } // 純粋なリノート(引用リノートでないリノート)の場合 - if (isRenotePacked(note) && !isQuotePacked(note) && note.renote) { + if (note.renote && isRenotePacked(note) && !isQuotePacked(note)) { if (!this.withRenotes) return; if (note.renote.reply) { const reply = note.renote.reply; diff --git a/packages/backend/src/server/api/stream/channels/home-timeline.ts b/packages/backend/src/server/api/stream/channels/home-timeline.ts index 9c2b60fd6..68822aa5d 100644 --- a/packages/backend/src/server/api/stream/channels/home-timeline.ts +++ b/packages/backend/src/server/api/stream/channels/home-timeline.ts @@ -71,7 +71,7 @@ class HomeTimelineChannel extends Channel { } // 純粋なリノート(引用リノートでないリノート)の場合 - if (isRenotePacked(note) && !isQuotePacked(note) && note.renote) { + if (note.renote && isRenotePacked(note) && !isQuotePacked(note)) { if (!this.withRenotes) return; if (note.renote.reply) { const reply = note.renote.reply; diff --git a/packages/backend/src/server/api/stream/channels/hybrid-timeline.ts b/packages/backend/src/server/api/stream/channels/hybrid-timeline.ts index 1a5c16889..39b7b8b64 100644 --- a/packages/backend/src/server/api/stream/channels/hybrid-timeline.ts +++ b/packages/backend/src/server/api/stream/channels/hybrid-timeline.ts @@ -85,7 +85,7 @@ class HybridTimelineChannel extends Channel { } // 純粋なリノート(引用リノートでないリノート)の場合 - if (isRenotePacked(note) && !isQuotePacked(note) && note.renote) { + if (note.renote && isRenotePacked(note) && !isQuotePacked(note)) { if (!this.withRenotes) return; if (note.renote.reply) { const reply = note.renote.reply; diff --git a/packages/backend/src/server/api/stream/channels/local-timeline.ts b/packages/backend/src/server/api/stream/channels/local-timeline.ts index 0a7f0d258..c191be84e 100644 --- a/packages/backend/src/server/api/stream/channels/local-timeline.ts +++ b/packages/backend/src/server/api/stream/channels/local-timeline.ts @@ -70,7 +70,7 @@ class LocalTimelineChannel extends Channel { } // 純粋なリノート(引用リノートでないリノート)の場合 - if (isRenotePacked(note) && !isQuotePacked(note) && note.renote) { + if (note.renote && isRenotePacked(note) && !isQuotePacked(note)) { if (!this.withRenotes) return; if (note.renote.reply) { const reply = note.renote.reply; diff --git a/packages/backend/src/server/api/stream/channels/role-timeline.ts b/packages/backend/src/server/api/stream/channels/role-timeline.ts index a19f22cf6..6fabdcb75 100644 --- a/packages/backend/src/server/api/stream/channels/role-timeline.ts +++ b/packages/backend/src/server/api/stream/channels/role-timeline.ts @@ -54,7 +54,7 @@ class RoleTimelineChannel extends Channel { } // 純粋なリノート(引用リノートでないリノート)の場合 - if (isRenotePacked(note) && !isQuotePacked(note) && note.renote) { + if (note.renote && isRenotePacked(note) && !isQuotePacked(note)) { if (note.renote.reply) { const reply = note.renote.reply; // 自分のフォローしていないユーザーの visibility: followers な投稿への返信のリノートは弾く diff --git a/packages/backend/src/server/api/stream/channels/user-list.ts b/packages/backend/src/server/api/stream/channels/user-list.ts index e92791898..297c253c4 100644 --- a/packages/backend/src/server/api/stream/channels/user-list.ts +++ b/packages/backend/src/server/api/stream/channels/user-list.ts @@ -110,7 +110,7 @@ class UserListChannel extends Channel { } // 純粋なリノート(引用リノートでないリノート)の場合 - if (isRenotePacked(note) && !isQuotePacked(note) && note.renote) { + if (note.renote && isRenotePacked(note) && !isQuotePacked(note)) { if (!this.withRenotes) return; if (note.renote.reply) { const reply = note.renote.reply;