From 9f8e1e5579bceaf85cf8e89ddd2e1b7c06589e5a Mon Sep 17 00:00:00 2001 From: Laura Hausmann Date: Thu, 12 Oct 2023 00:29:18 +0200 Subject: [PATCH] [mastodon-client] Don't duplicate quote uri if it's already in the note text --- .../backend/src/server/api/mastodon/converters/note.ts | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/packages/backend/src/server/api/mastodon/converters/note.ts b/packages/backend/src/server/api/mastodon/converters/note.ts index e9f2300c9..287f9e9ad 100644 --- a/packages/backend/src/server/api/mastodon/converters/note.ts +++ b/packages/backend/src/server/api/mastodon/converters/note.ts @@ -88,9 +88,11 @@ export class NoteConverter { .then(p => p.filter(m => m)) as Promise; const text = Promise.resolve(renote).then(renote => { - return renote && note.text !== null - ? note.text + `\n\nRE: ${renote.uri ? renote.uri : `${config.url}/notes/${renote.id}`}` - : note.text; + if (!renote || note.text === null) return note.text + const uri = renote.uri ? renote.uri : `${config.url}/notes/${renote.id}`; + return note.text.includes(uri) + ? note.text + : note.text + `\n\nRE: ${uri}`; }); const isPinned = user && note.userId === user.id