From 34aeeb0862da152b91ea3496c199cf1de631d570 Mon Sep 17 00:00:00 2001 From: Hazel K Date: Tue, 1 Oct 2024 14:44:16 -0400 Subject: [PATCH 1/4] respect CWs in note summaries --- packages/backend/src/misc/get-note-summary.ts | 10 ++++++---- packages/frontend/src/scripts/get-note-summary.ts | 10 ++++++---- 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/packages/backend/src/misc/get-note-summary.ts b/packages/backend/src/misc/get-note-summary.ts index 1a07139a50..5038106870 100644 --- a/packages/backend/src/misc/get-note-summary.ts +++ b/packages/backend/src/misc/get-note-summary.ts @@ -18,13 +18,15 @@ export const getNoteSummary = (note: Packed<'Note'>): string => { return '(⛔)'; } + if (note.cw != null) { + return `CW: ${note.cw}`; + } + let summary = ''; // 本文 - if (note.cw != null) { - summary += note.cw; - } else { - summary += note.text ? note.text : ''; + if (note.text) { + summary += note.text; } // ファイルが添付されているとき diff --git a/packages/frontend/src/scripts/get-note-summary.ts b/packages/frontend/src/scripts/get-note-summary.ts index 6fd9947ac1..85903231a4 100644 --- a/packages/frontend/src/scripts/get-note-summary.ts +++ b/packages/frontend/src/scripts/get-note-summary.ts @@ -23,13 +23,15 @@ export const getNoteSummary = (note?: Misskey.entities.Note | null): string => { return `(${i18n.ts.invisibleNote})`; } + if (note.cw != null) { + return `CW: ${note.cw}`; + } + let summary = ''; // 本文 - if (note.cw != null) { - summary += note.cw; - } else { - summary += note.text ? note.text : ''; + if (note.text) { + summary += note.text; } // ファイルが添付されているとき From 94ce7272a72b95d093d79164f4b3049e00323bb7 Mon Sep 17 00:00:00 2001 From: Hazel K Date: Tue, 1 Oct 2024 14:44:34 -0400 Subject: [PATCH 2/4] avoid TS errors in get-note-summary --- packages/backend/src/misc/get-note-summary.ts | 4 ++-- packages/frontend/src/scripts/get-note-summary.ts | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/packages/backend/src/misc/get-note-summary.ts b/packages/backend/src/misc/get-note-summary.ts index 5038106870..58938d3b32 100644 --- a/packages/backend/src/misc/get-note-summary.ts +++ b/packages/backend/src/misc/get-note-summary.ts @@ -30,8 +30,8 @@ export const getNoteSummary = (note: Packed<'Note'>): string => { } // ファイルが添付されているとき - if ((note.files ?? []).length !== 0) { - summary += ` (📎${note.files!.length})`; + if (note.files && note.files.length !== 0) { + summary += ` (📎${note.files.length})`; } // 投票が添付されているとき diff --git a/packages/frontend/src/scripts/get-note-summary.ts b/packages/frontend/src/scripts/get-note-summary.ts index 85903231a4..d695b3a062 100644 --- a/packages/frontend/src/scripts/get-note-summary.ts +++ b/packages/frontend/src/scripts/get-note-summary.ts @@ -35,7 +35,7 @@ export const getNoteSummary = (note?: Misskey.entities.Note | null): string => { } // ファイルが添付されているとき - if ((note.files || []).length !== 0) { + if (note.files && note.files.length !== 0) { summary += ` (${i18n.tsx.withNFiles({ n: note.files.length })})`; } From cb10fe91bb425f5e01e9c884fff824dea269705a Mon Sep 17 00:00:00 2001 From: Hazel K Date: Tue, 1 Oct 2024 18:26:59 -0400 Subject: [PATCH 3/4] preserve non-text details in note summaries --- packages/backend/src/misc/get-note-summary.ts | 8 +++----- packages/frontend/src/scripts/get-note-summary.ts | 8 +++----- 2 files changed, 6 insertions(+), 10 deletions(-) diff --git a/packages/backend/src/misc/get-note-summary.ts b/packages/backend/src/misc/get-note-summary.ts index 58938d3b32..2652294103 100644 --- a/packages/backend/src/misc/get-note-summary.ts +++ b/packages/backend/src/misc/get-note-summary.ts @@ -18,14 +18,12 @@ export const getNoteSummary = (note: Packed<'Note'>): string => { return '(⛔)'; } - if (note.cw != null) { - return `CW: ${note.cw}`; - } - let summary = ''; // 本文 - if (note.text) { + if (note.cw != null) { + summary += `CW: ${note.cw}`; + } else if (note.text) { summary += note.text; } diff --git a/packages/frontend/src/scripts/get-note-summary.ts b/packages/frontend/src/scripts/get-note-summary.ts index d695b3a062..6c70ced67f 100644 --- a/packages/frontend/src/scripts/get-note-summary.ts +++ b/packages/frontend/src/scripts/get-note-summary.ts @@ -23,14 +23,12 @@ export const getNoteSummary = (note?: Misskey.entities.Note | null): string => { return `(${i18n.ts.invisibleNote})`; } - if (note.cw != null) { - return `CW: ${note.cw}`; - } - let summary = ''; // 本文 - if (note.text) { + if (note.cw != null) { + summary += `CW: ${note.cw}`; + } else if (note.text) { summary += note.text; } From c0583e5d5c6f74f96f173d38e6f675508a54639a Mon Sep 17 00:00:00 2001 From: Hazel K Date: Wed, 2 Oct 2024 00:54:35 -0400 Subject: [PATCH 4/4] don't leak boost / quote / reply contents when CW is in effect --- packages/backend/src/misc/get-note-summary.ts | 4 ++-- packages/frontend/src/scripts/get-note-summary.ts | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/packages/backend/src/misc/get-note-summary.ts b/packages/backend/src/misc/get-note-summary.ts index 2652294103..60dddee9a2 100644 --- a/packages/backend/src/misc/get-note-summary.ts +++ b/packages/backend/src/misc/get-note-summary.ts @@ -39,7 +39,7 @@ export const getNoteSummary = (note: Packed<'Note'>): string => { // 返信のとき if (note.replyId) { - if (note.reply) { + if (note.reply && !note.cw) { summary += `\n\nRE: ${getNoteSummary(note.reply)}`; } else { summary += '\n\nRE: ...'; @@ -48,7 +48,7 @@ export const getNoteSummary = (note: Packed<'Note'>): string => { // Renoteのとき if (note.renoteId) { - if (note.renote) { + if (note.renote && !note.cw) { summary += `\n\nRN: ${getNoteSummary(note.renote)}`; } else { summary += '\n\nRN: ...'; diff --git a/packages/frontend/src/scripts/get-note-summary.ts b/packages/frontend/src/scripts/get-note-summary.ts index 6c70ced67f..58d486bf9b 100644 --- a/packages/frontend/src/scripts/get-note-summary.ts +++ b/packages/frontend/src/scripts/get-note-summary.ts @@ -44,7 +44,7 @@ export const getNoteSummary = (note?: Misskey.entities.Note | null): string => { // 返信のとき if (note.replyId) { - if (note.reply) { + if (note.reply && !note.cw) { summary += `\n\nRE: ${getNoteSummary(note.reply)}`; } else { summary += '\n\nRE: ...'; @@ -53,7 +53,7 @@ export const getNoteSummary = (note?: Misskey.entities.Note | null): string => { // Renoteのとき if (note.renoteId) { - if (note.renote) { + if (note.renote && !note.cw) { summary += `\n\nRN: ${getNoteSummary(note.renote)}`; } else { summary += '\n\nRN: ...';