diff --git a/src/d2m/converters/edit-to-changes.test.js b/src/d2m/converters/edit-to-changes.test.js index b252175..d687702 100644 --- a/src/d2m/converters/edit-to-changes.test.js +++ b/src/d2m/converters/edit-to-changes.test.js @@ -181,12 +181,7 @@ test("edit2changes: edit of reply to skull webp attachment with content", async newContent: { $type: "m.room.message", msgtype: "m.text", - body: "> Extremity: Image\n\n* Edit", - format: "org.matrix.custom.html", - formatted_body: - '
In reply to Extremity' - + '
Image
' - + '* Edit', + body: "* Edit", "m.mentions": {}, "m.new_content": { msgtype: "m.text", diff --git a/src/d2m/converters/message-to-event.js b/src/d2m/converters/message-to-event.js index 1c92123..11e82a5 100644 --- a/src/d2m/converters/message-to-event.js +++ b/src/d2m/converters/message-to-event.js @@ -508,15 +508,13 @@ async function messageToEvent(message, guild, options = {}, di) { // Generate a reply pointing to the Matrix event we found const latestRoomID = select("channel_room", "room_id", {channel_id: repliedToEventRow.channel_id}).pluck().get() // native replies don't work across room upgrades, so make sure the old and new message are in the same room if (latestRoomID !== repliedToEventRow.room_id) repliedToEventInDifferentRoom = true - html = - (latestRoomID === repliedToEventRow.room_id ? "" : "") - + `
In reply to ${repliedToUserHtml}` + html = repliedToEventInDifferentRoom ? + (`
In reply to ${repliedToUserHtml}` + `
${repliedToHtml}
` - + (latestRoomID === repliedToEventRow.room_id ? "" : "") - + html - body = (`${repliedToDisplayName}: ` // scenario 1 part B for mentions + + html) : html + body = repliedToEventInDifferentRoom ? ((`${repliedToDisplayName}: ` // scenario 1 part B for mentions + repliedToBody).split("\n").map(line => "> " + line).join("\n") - + "\n\n" + body + + "\n\n" + body) : body } else { // repliedToUnknownEvent // This reply can't point to the Matrix event because it isn't bridged, we need to indicate this. assert(message.referenced_message) diff --git a/src/d2m/converters/message-to-event.pk.test.js b/src/d2m/converters/message-to-event.pk.test.js index ce83d54..1323280 100644 --- a/src/d2m/converters/message-to-event.pk.test.js +++ b/src/d2m/converters/message-to-event.pk.test.js @@ -50,11 +50,7 @@ test("message2event: pk reply to matrix is converted to native matrix reply", as ] }, msgtype: "m.text", - body: "> cadence [they]: now for my next experiment:\n\nthis is a reply", - format: "org.matrix.custom.html", - formatted_body: '
In reply to cadence [they]
' - + "now for my next experiment:
" - + "this is a reply", + body: "this is a reply", "m.relates_to": { "m.in_reply_to": { event_id: "$NB6nPgO2tfXyIwwDSF0Ga0BUrsgX1S-0Xl-jAvI8ucU" @@ -80,11 +76,7 @@ test("message2event: pk reply to discord is converted to native matrix reply", a $type: "m.room.message", msgtype: "m.text", "m.mentions": {}, - body: "> wing: some text\n\nthis is a reply", - format: "org.matrix.custom.html", - formatted_body: '
In reply to wing
' - + "some text
" - + "this is a reply", + body: "this is a reply", "m.relates_to": { "m.in_reply_to": { event_id: "$mtR8cJqM4fKno1bVsm8F4wUVqSntt2sq6jav1lyavuA" @@ -120,11 +112,7 @@ test("message2event: pk reply to matrix attachment is converted to native matrix "m.mentions": { user_ids: ["@ampflower:matrix.org"] }, - body: "> Ampflower 🌺: [Media]\n\nCat nod", - format: "org.matrix.custom.html", - formatted_body: '
In reply to Ampflower 🌺
' - + "[Media]
" - + "Cat nod", + body: "Cat nod", "m.relates_to": { "m.in_reply_to": { event_id: "$OEEK-Wam2FTh6J-6kVnnJ6KnLA_lLRnLTHatKKL62-Y" diff --git a/src/d2m/converters/message-to-event.test.js b/src/d2m/converters/message-to-event.test.js index f7769d3..a527ad8 100644 --- a/src/d2m/converters/message-to-event.test.js +++ b/src/d2m/converters/message-to-event.test.js @@ -423,12 +423,7 @@ test("message2event: reply to skull webp attachment with content", async t => { }, "m.mentions": {}, msgtype: "m.text", - body: "> Extremity: Image\n\nReply", - format: "org.matrix.custom.html", - formatted_body: - '
In reply to Extremity' - + '
Image
' - + 'Reply' + body: "Reply" }, { $type: "m.room.message", "m.mentions": {}, @@ -472,12 +467,7 @@ test("message2event: simple reply to matrix user", async t => { ] }, msgtype: "m.text", - body: "> cadence: so can you reply to my webhook uwu\n\nReply", - format: "org.matrix.custom.html", - formatted_body: - '
In reply to cadence' - + '
so can you reply to my webhook uwu
' - + 'Reply' + body: "Reply" }]) }) @@ -539,12 +529,7 @@ test("message2event: reply to matrix user with mention", async t => { ] }, msgtype: "m.text", - body: "> okay 🤍 yay 🤍: @extremity: you owe me $30\n\nkys", - format: "org.matrix.custom.html", - formatted_body: - '
In reply to okay 🤍 yay 🤍' - + '
@extremity you owe me $30
' - + 'kys' + body: "kys" }]) }) @@ -656,9 +641,7 @@ test("message2event: simple reply in thread to a matrix user's reply", async t = user_ids: ["@cadence:cadence.moe"] }, msgtype: "m.text", - body: "> cadence [they]: What about them?\n\nWell, they don't seem to...", - format: "org.matrix.custom.html", - formatted_body: "
In reply to cadence [they]
What about them?
Well, they don't seem to...", + body: "Well, they don't seem to..." }]) }) @@ -695,9 +678,7 @@ test("message2event: infinidoge's reply to ami's matrix smalltext reply to infin user_ids: ["@ami:the-apothecary.club"] }, msgtype: "m.text", - body: `> Ami (she/her): let me guess they got a lot of bug reports like "empty chest with no loot?"\n\nMost likely`, - format: "org.matrix.custom.html", - formatted_body: `
In reply to Ami (she/her)
let me guess they got a lot of bug reports like "empty chest with no loot?"
Most likely`, + body: `Most likely` }]) }) @@ -734,9 +715,7 @@ test("message2event: infinidoge's reply to ami's matrix smalltext singleline rep user_ids: ["@ami:the-apothecary.club"] }, msgtype: "m.text", - body: `> Ami (she/her): let me guess they got a lot of bug reports like "empty chest with no loot?"\n\nMost likely`, - format: "org.matrix.custom.html", - formatted_body: `
In reply to Ami (she/her)
let me guess they got a lot of bug reports like "empty chest with no loot?"
Most likely`, + body: `Most likely` }]) })