From 49fd4034744f7642210bb66a3558d544d67e13b8 Mon Sep 17 00:00:00 2001 From: Johann150 Date: Thu, 6 Jul 2023 12:46:19 -0700 Subject: [PATCH] =?UTF-8?q?fix:=20=F0=9F=90=9B=20fix=20quotes=20with=20CW-?= =?UTF-8?q?only=20quotes?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../backend/src/server/activitypub/outbox.ts | 2 +- packages/backend/src/services/note/create.ts | 28 +++++-------------- packages/client/src/components/MkNote.vue | 1 + 3 files changed, 9 insertions(+), 22 deletions(-) diff --git a/packages/backend/src/server/activitypub/outbox.ts b/packages/backend/src/server/activitypub/outbox.ts index e0a380ffb..469bd62ec 100644 --- a/packages/backend/src/server/activitypub/outbox.ts +++ b/packages/backend/src/server/activitypub/outbox.ts @@ -138,7 +138,7 @@ export async function packActivity(note: Note): Promise { ) { const renote = await Notes.findOneByOrFail({ id: note.renoteId }); return renderAnnounce( - renote.uri ? renote.uri : `${config.url}/notes/${renote.id}`, + renote.uri ?? `${config.url}/notes/${renote.id}`, note, ); } diff --git a/packages/backend/src/services/note/create.ts b/packages/backend/src/services/note/create.ts index 095c75f42..12c501533 100644 --- a/packages/backend/src/services/note/create.ts +++ b/packages/backend/src/services/note/create.ts @@ -67,6 +67,7 @@ import { shouldSilenceInstance } from "@/misc/should-block-instance.js"; import meilisearch from "../../db/meilisearch.js"; import { redisClient } from "@/db/redis.js"; import { Mutex } from "redis-semaphore"; +import { packActivity } from "@/server/activitypub/outbox.js"; const mutedWordsCache = new Cache< { userId: UserProfile["userId"]; mutedWords: UserProfile["mutedWords"] }[] @@ -596,9 +597,13 @@ export default async ( }); //#region AP deliver - if (Users.isLocalUser(user) && !dontFederateInitially) { + if ( + Users.isLocalUser(user) && + !data.localOnly && + !dontFederateInitially + ) { (async () => { - const noteActivity = await renderNoteOrRenoteActivity(data, note); + const noteActivity = renderActivity(await packActivity(note)); const dm = new DeliverManager(user, noteActivity); // メンションされたリモートユーザーに配送 @@ -655,25 +660,6 @@ export default async ( await index(note, false); }); -async function renderNoteOrRenoteActivity(data: Option, note: Note) { - if (data.localOnly) return null; - - const content = - data.renote && - data.text == null && - data.poll == null && - (data.files == null || data.files.length === 0) - ? renderAnnounce( - data.renote.uri - ? data.renote.uri - : `${config.url}/notes/${data.renote.id}`, - note, - ) - : renderCreate(await renderNote(note, false), note); - - return renderActivity(content); -} - function incRenoteCount(renote: Note) { Notes.createQueryBuilder() .update() diff --git a/packages/client/src/components/MkNote.vue b/packages/client/src/components/MkNote.vue index a1a519f79..a7ed28480 100644 --- a/packages/client/src/components/MkNote.vue +++ b/packages/client/src/components/MkNote.vue @@ -328,6 +328,7 @@ if (noteViewInterruptors.length > 0) { const isRenote = note.renote != null && note.text == null && + note.cw == null && note.fileIds.length === 0 && note.poll == null;