From 52b94dbc4ab60aa6efba927ef8df509a3bb0d046 Mon Sep 17 00:00:00 2001 From: anatawa12 Date: Fri, 22 Dec 2023 14:03:39 +0900 Subject: [PATCH] =?UTF-8?q?fix:=20=E5=BC=95=E7=94=A8RN=E3=81=8Cpure=20RN?= =?UTF-8?q?=E3=81=A8=E3=81=97=E3=81=A6=E9=80=A3=E5=90=88=E3=81=95=E3=82=8C?= =?UTF-8?q?=E3=80=81pure=20RN=E3=81=8C=E5=BC=95=E7=94=A8RN=E3=81=A8?= =?UTF-8?q?=E3=81=97=E3=81=A6=E9=80=A3=E5=90=88=E3=81=95=E3=82=8C=E3=82=8B?= =?UTF-8?q?=20(#12744)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * fix: quote notes are rendered as pure renote * fix: filesが指定されてて空配列のときにQuote扱いされる * chore: isQuoteの仕様をmisc/is-quote.tsと揃える * docs: is-quote.tsの方にNoteCreateService.isQuoteのことを書いて更新忘れを防ぐ --- packages/backend/src/core/NoteCreateService.ts | 9 +++++---- packages/backend/src/misc/is-quote.ts | 1 + 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/packages/backend/src/core/NoteCreateService.ts b/packages/backend/src/core/NoteCreateService.ts index 9fe965b139..54493612b8 100644 --- a/packages/backend/src/core/NoteCreateService.ts +++ b/packages/backend/src/core/NoteCreateService.ts @@ -293,7 +293,7 @@ export class NoteCreateService implements OnApplicationShutdown { } // Check blocking - if (data.renote && this.isQuote(data)) { + if (this.isQuote(data)) { if (data.renote.userHost === null) { if (data.renote.userId !== user.id) { const blocked = await this.userBlockingService.checkBlocked(data.renote.userId, user.id); @@ -730,8 +730,9 @@ export class NoteCreateService implements OnApplicationShutdown { } @bindThis - private isQuote(note: Option): boolean { - return !!note.text || !!note.cw || !!note.files || !!note.poll; + private isQuote(note: Option): note is Option & { renote: MiNote } { + // sync with misc/is-quote.ts + return !!note.renote && (!!note.text || !!note.cw || (!!note.files && !!note.files.length) || !!note.poll); } @bindThis @@ -799,7 +800,7 @@ export class NoteCreateService implements OnApplicationShutdown { private async renderNoteOrRenoteActivity(data: Option, note: MiNote) { if (data.localOnly) return null; - const content = data.renote && this.isQuote(data) + const content = data.renote && !this.isQuote(data) ? this.apRendererService.renderAnnounce(data.renote.uri ? data.renote.uri : `${this.config.url}/notes/${data.renote.id}`, note) : this.apRendererService.renderCreate(await this.apRendererService.renderNote(note, false), note); diff --git a/packages/backend/src/misc/is-quote.ts b/packages/backend/src/misc/is-quote.ts index 059f6a4b5f..db72d1d57a 100644 --- a/packages/backend/src/misc/is-quote.ts +++ b/packages/backend/src/misc/is-quote.ts @@ -7,5 +7,6 @@ import type { MiNote } from '@/models/Note.js'; // eslint-disable-next-line import/no-default-export export default function(note: MiNote): boolean { + // sync with NoteCreateService.isQuote return note.renoteId != null && (note.text != null || note.hasPoll || (note.fileIds != null && note.fileIds.length > 0)); }