diff --git a/m2d/converters/event-to-message.js b/m2d/converters/event-to-message.js
index 5ad62c1..1eb1be2 100644
--- a/m2d/converters/event-to-message.js
+++ b/m2d/converters/event-to-message.js
@@ -210,7 +210,7 @@ async function eventToMessage(event, guild, di) {
replyLine += `Ⓜ️**${senderName}**:`
}
const repliedToContent = repliedToEvent.content.formatted_body || repliedToEvent.content.body
- const contentPreviewChunks = chunk(repliedToContent.replace(/.*<\/mx-reply>/, "").replace(/(?:\n|
)+/g, " ").replace(/<[^>]+>/g, ""), 50)
+ const contentPreviewChunks = chunk(repliedToContent.replace(/.*<\/mx-reply>/, "").replace(/.*?<\/blockquote>/, "").replace(/(?:\n|
)+/g, " ").replace(/<[^>]+>/g, ""), 50)
const contentPreview = contentPreviewChunks.length > 1 ? contentPreviewChunks[0] + "..." : contentPreviewChunks[0]
replyLine = `> ${replyLine}\n> ${contentPreview}\n`
})()
diff --git a/m2d/converters/event-to-message.test.js b/m2d/converters/event-to-message.test.js
index 565d8c4..e9061b7 100644
--- a/m2d/converters/event-to-message.test.js
+++ b/m2d/converters/event-to-message.test.js
@@ -535,6 +535,55 @@ test("event2message: rich reply to a sim user", async t => {
)
})
+test("event2message: should avoid using blockquote contents as reply preview in rich reply to a sim user", async t => {
+ t.deepEqual(
+ await eventToMessage({
+ type: "m.room.message",
+ sender: "@cadence:cadence.moe",
+ content: {
+ msgtype: "m.text",
+ body: "> <@_ooye_kyuugryphon:cadence.moe> > well, you said this, so...\n> \n> that can't be true! there's no way :o\n\nI agree!",
+ format: "org.matrix.custom.html",
+ formatted_body: "In reply to @_ooye_kyuugryphon:cadence.moe
well, you said this, so...
that can't be true! there's no way :o
I agree!",
+ "m.relates_to": {
+ "m.in_reply_to": {
+ event_id: "$Fxy8SMoJuTduwReVkHZ1uHif9EuvNx36Hg79cltiA04"
+ }
+ }
+ },
+ event_id: "$BpGx8_vqHyN6UQDARPDU51ftrlRBhleutRSgpAJJ--g",
+ room_id: "!fGgIymcYWOqjbSRUdV:cadence.moe"
+ }, data.guild.general, {
+ api: {
+ getEvent: mockGetEvent(t, "!fGgIymcYWOqjbSRUdV:cadence.moe", "$Fxy8SMoJuTduwReVkHZ1uHif9EuvNx36Hg79cltiA04", {
+ "type": "m.room.message",
+ "sender": "@_ooye_kyuugryphon:cadence.moe",
+ "content": {
+ "m.mentions": {},
+ "msgtype": "m.text",
+ "body": "> well, you said this, so...\n\nthat can't be true! there's no way :o",
+ "format": "org.matrix.custom.html",
+ "formatted_body": "
well, you said this, so...
that can't be true! there's no way :o"
+ }
+ })
+ }
+ }),
+ {
+ messagesToDelete: [],
+ messagesToEdit: [],
+ messagesToSend: [{
+ username: "cadence [they]",
+ content: "> <:L1:1144820033948762203><:L2:1144820084079087647>https://discord.com/channels/112760669178241024/687028734322147344/1144865310588014633 <@111604486476181504>:"
+ + "\n> that can't be true! there's no way :o"
+ + "\nI agree!",
+ avatar_url: "https://matrix.cadence.moe/_matrix/media/r0/download/cadence.moe/azCAhThKTojXSZJRoWwZmhvU"
+ }]
+ }
+ )
+})
+
+
+
test("event2message: editing a rich reply to a sim user", async t => {
const eventsFetched = []
t.deepEqual(
diff --git a/notes.md b/notes.md
index 0b6b088..458e3bd 100644
--- a/notes.md
+++ b/notes.md
@@ -2,14 +2,13 @@
## Known issues
-- m->d attachments do not work
-- m->d replying to a message that used a blockquote should avoid using the blockquote contents as the preview
- d->m emojis do not work at all (inline chat, single emoji size, reactions, bridged state)
+- d->m embeds
- m->d code blocks have slightly too much spacing
-- m->d some reactions don't work because of the variation selector
- d->m check whether I implemented deletions
- m->d deletions
-- rooms will be set up even if the bridge does not have permission for them, then break when it restarts and tries to reach messages
+- removing reactions
+- rooms will be set up even if the bridge does not have permission for the channels, which breaks when it restarts and tries to fetch messages
- test private threads as part of this
- solution part 1: calculate the permissions to see if the bot should be able to do stuff
- solution part 2: attempt a get messages request anyway before bridging a new room, just to make sure!