diff options
| author | Hazelnoot <acomputerdog@gmail.com> | 2025-02-12 14:47:38 -0500 |
|---|---|---|
| committer | Hazelnoot <acomputerdog@gmail.com> | 2025-02-16 19:20:41 -0500 |
| commit | 3d23cdc0e45ceee3fbcb7acb7f2e7922664a33bb (patch) | |
| tree | 87d9d2c8c677b133f5b49d7368e92916a82f53cd /packages | |
| parent | append mandatory CW in all note views (Mk/Sk/Em + basic/Detailed/Simple/Sub) (diff) | |
| download | sharkey-3d23cdc0e45ceee3fbcb7acb7f2e7922664a33bb.tar.gz sharkey-3d23cdc0e45ceee3fbcb7acb7f2e7922664a33bb.tar.bz2 sharkey-3d23cdc0e45ceee3fbcb7acb7f2e7922664a33bb.zip | |
append mandatory CW in note previews
Diffstat (limited to 'packages')
| -rw-r--r-- | packages/backend/src/misc/get-note-summary.ts | 11 | ||||
| -rw-r--r-- | packages/frontend/src/scripts/get-note-summary.ts | 11 |
2 files changed, 18 insertions, 4 deletions
diff --git a/packages/backend/src/misc/get-note-summary.ts b/packages/backend/src/misc/get-note-summary.ts index 60dddee9a2..be2d3ea98d 100644 --- a/packages/backend/src/misc/get-note-summary.ts +++ b/packages/backend/src/misc/get-note-summary.ts @@ -3,6 +3,7 @@ * SPDX-License-Identifier: AGPL-3.0-only */ +import { appendContentWarning } from './append-content-warning.js'; import type { Packed } from './json-schema.js'; /** @@ -20,9 +21,15 @@ export const getNoteSummary = (note: Packed<'Note'>): string => { let summary = ''; + // Append mandatory CW, if applicable + let cw = note.cw; + if (note.user.mandatoryCW) { + cw = appendContentWarning(cw, note.user.mandatoryCW); + } + // 本文 - if (note.cw != null) { - summary += `CW: ${note.cw}`; + if (cw != null) { + summary += `CW: ${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 58d486bf9b..4e093bcf4c 100644 --- a/packages/frontend/src/scripts/get-note-summary.ts +++ b/packages/frontend/src/scripts/get-note-summary.ts @@ -4,6 +4,7 @@ */ import * as Misskey from 'misskey-js'; +import { appendContentWarning } from '@@/js/append-content-warning.js'; import { i18n } from '@/i18n.js'; /** @@ -25,9 +26,15 @@ export const getNoteSummary = (note?: Misskey.entities.Note | null): string => { let summary = ''; + // Append mandatory CW, if applicable + let cw = note.cw; + if (note.user.mandatoryCW) { + cw = appendContentWarning(cw, note.user.mandatoryCW); + } + // 本文 - if (note.cw != null) { - summary += `CW: ${note.cw}`; + if (cw != null) { + summary += `CW: ${cw}`; } else if (note.text) { summary += note.text; } |