~cadence/matrix-appservice-discord

2410308e8ad7c40dd41eb26ae5e1b06a6ec1b9b8 — Cadence Ember 6 months ago d139d81 main
fix previous commit: evaluate quoted username
1 files changed, 4 insertions(+), 6 deletions(-)

M src/discordmessageprocessor.ts
M src/discordmessageprocessor.ts => src/discordmessageprocessor.ts +4 -6
@@ 107,14 107,8 @@ export class DiscordMessageProcessor {
        if (msg.messageReference && msg.messageReference.message_id) {
            // if there is content, insert the content into the matrix message too. this legacy display is used by element android
            if (msg.messageReference.message && msg.messageReference.message.content && msg.messageReference.message.author && msg.messageReference.message.author.username) {
                // > <@she_who_brings_destruction:cadence.moe> https://twitter.com/NutDivide/status/1484418483018354688\n\ncum
                // <mx-reply><blockquote><a href=\"https://matrix.to/#/!JVDXYBIKlkpdnIfHuh:cadence.moe/$xHmIH-oQwva6kHg4drvUVbCy-yrut1u_4d3gTeZbY90?via=cadence.moe\">In reply to</a> <a href=\"https://matrix.to/#/@she_who_brings_destruction:cadence.moe\">@she_who_brings_destruction:cadence.moe</a><br>https://twitter.com/NutDivide/status/1484418483018354688</blockquote></mx-reply>cum
                const quotedUsername = msg.messageReference.message.author.username
                const quotedContent = msg.messageReference.message.content
                // body
                let block = "<quotedUsername>: " + quotedContent
                let reQuoted = block.split("\n").map(line => "> " + line).join("\n")
                result.body = reQuoted + "\n\n" + result.body
                // formatted body
                const quotedContentPostmark = markdown.toHTML(quotedContent, {
                    discordCallback: this.getDiscordParseCallbacksHTML(msg),


@@ 125,6 119,10 @@ export class DiscordMessageProcessor {
                    escapeHTML: true,
                });
                result.formattedBody = `<mx-reply><blockquote><em>In reply to ${escapedUsername}</em><br>${quotedContentPostmark}</blockquote></mx-reply>` + result.formattedBody
                // body
                let block = `<${quotedUsername}>: ${quotedContent}`
                let reQuoted = block.split("\n").map(line => "> " + line).join("\n")
                result.body = reQuoted + "\n\n" + result.body
            }
            // try to look up the message, and set the m.reply_to field (this makes it display on element desktop and fluffychat)
            const storeEvent = await this.opts.bot!.store.Get(DbEvent, {discord_id: msg.messageReference.message_id});