m->d: Remove rare "In reply to" fallback text

This commit is contained in:
Cadence Ember 2024-01-10 22:42:13 +13:00
parent 8e3b674d90
commit d0a3c3ce29
2 changed files with 83 additions and 15 deletions

View file

@ -429,7 +429,7 @@ async function eventToMessage(event, guild, di) {
const repliedToContent = repliedToEvent.content.formatted_body || repliedToEvent.content.body
const contentPreviewChunks = chunk(
entities.decodeHTML5Strict( // Remove entities like & "
repliedToContent.replace(/.*<\/mx-reply>/, "") // Remove everything before replies, so just use the actual message body
repliedToContent.replace(/.*<\/mx-reply>/s, "") // Remove everything before replies, so just use the actual message body
.replace(/^\s*<blockquote>.*?<\/blockquote>(.....)/s, "$1") // If the message starts with a blockquote, don't count it and use the message body afterwards
.replace(/(?:\n|<br>)+/g, " ") // Should all be on one line
.replace(/<span [^>]*data-mx-spoiler\b[^>]*>.*?<\/span>/g, "[spoiler]") // Good enough method of removing spoiler content. (I don't want to break out the HTML parser unless I have to.)