[mastodon-client] Don't duplicate quote uri if it's already in the note text

This commit is contained in:
Laura Hausmann 2023-10-12 00:29:18 +02:00
parent 44c70df1a6
commit 9f8e1e5579
No known key found for this signature in database
GPG Key ID: D044E84C5BE01605

View File

@ -88,9 +88,11 @@ export class NoteConverter {
.then(p => p.filter(m => m)) as Promise<MastodonEntity.Mention[]>;
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