From 1ad0eec00d48a3b50ed8e068aa86688ac2419e26 Mon Sep 17 00:00:00 2001 From: Kainoa Kanter Date: Thu, 6 Jul 2023 21:53:44 +0000 Subject: [PATCH] revert 49fd4034744f7642210bb66a3558d544d67e13b8 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit revert fix: πŸ› fix quotes with CW-only quotes --- .../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, 22 insertions(+), 9 deletions(-) diff --git a/packages/backend/src/server/activitypub/outbox.ts b/packages/backend/src/server/activitypub/outbox.ts index 469bd62ec..e0a380ffb 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 ?? `${config.url}/notes/${renote.id}`, + renote.uri ? 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 12c501533..095c75f42 100644 --- a/packages/backend/src/services/note/create.ts +++ b/packages/backend/src/services/note/create.ts @@ -67,7 +67,6 @@ 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"] }[] @@ -597,13 +596,9 @@ export default async ( }); //#region AP deliver - if ( - Users.isLocalUser(user) && - !data.localOnly && - !dontFederateInitially - ) { + if (Users.isLocalUser(user) && !dontFederateInitially) { (async () => { - const noteActivity = renderActivity(await packActivity(note)); + const noteActivity = await renderNoteOrRenoteActivity(data, note); const dm = new DeliverManager(user, noteActivity); // γƒ‘γƒ³γ‚·γƒ§γƒ³γ•γ‚ŒγŸγƒͺγƒ’γƒΌγƒˆγƒ¦γƒΌγ‚ΆγƒΌγ«ι…ι€ @@ -660,6 +655,25 @@ 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 a7ed28480..a1a519f79 100644 --- a/packages/client/src/components/MkNote.vue +++ b/packages/client/src/components/MkNote.vue @@ -328,7 +328,6 @@ if (noteViewInterruptors.length > 0) { const isRenote = note.renote != null && note.text == null && - note.cw == null && note.fileIds.length === 0 && note.poll == null;