From 6a03c9698450d99c555fa593e73011dfc8b10c6b Mon Sep 17 00:00:00 2001 From: Cadence Ember Date: Sun, 27 Aug 2023 23:25:08 +1200 Subject: [PATCH] m->d move reply message preview to own line --- d2m/event-dispatcher.js | 8 ++++---- m2d/converters/event-to-message.js | 4 ++-- m2d/event-dispatcher.js | 8 ++++---- notes.md | 22 ++++++++++++++++++++++ 4 files changed, 32 insertions(+), 10 deletions(-) diff --git a/d2m/event-dispatcher.js b/d2m/event-dispatcher.js index 6939c59..049df27 100644 --- a/d2m/event-dispatcher.js +++ b/d2m/event-dispatcher.js @@ -61,10 +61,10 @@ module.exports = { formatted_body: "\u26a0 Bridged event from Discord not delivered" + `
Gateway event: ${gatewayMessage.t}` + `
${e.toString()}` - + `
Error trace` - + `
${stackLines.join("\n")}
` - + `
Original payload` - + `
${util.inspect(gatewayMessage.d, false, 4, false)}
`, + + `
Error trace` + + `
${stackLines.join("\n")}
` + + `
Original payload` + + `
${util.inspect(gatewayMessage.d, false, 4, false)}
`, "m.mentions": { user_ids: ["@cadence:cadence.moe"] } diff --git a/m2d/converters/event-to-message.js b/m2d/converters/event-to-message.js index 22ed377..534becb 100644 --- a/m2d/converters/event-to-message.js +++ b/m2d/converters/event-to-message.js @@ -173,9 +173,9 @@ 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, ""), 24) + const contentPreviewChunks = chunk(repliedToContent.replace(/.*<\/mx-reply>/, "").replace(/(?:\n|
)+/g, " ").replace(/<[^>]+>/g, ""), 50) const contentPreview = contentPreviewChunks.length > 1 ? contentPreviewChunks[0] + "..." : contentPreviewChunks[0] - replyLine += contentPreview + "\n" + replyLine = `> ${replyLine}\n> ${contentPreview}\n` })() // Handling mentions of Discord users diff --git a/m2d/event-dispatcher.js b/m2d/event-dispatcher.js index 9a575fc..6adacf7 100644 --- a/m2d/event-dispatcher.js +++ b/m2d/event-dispatcher.js @@ -40,10 +40,10 @@ function guard(type, fn) { formatted_body: "\u26a0 Matrix event not delivered to Discord" + `
Event type: ${type}` + `
${e.toString()}` - + `
Error trace` - + `
${stackLines.join("\n")}
` - + `
Original payload` - + `
${util.inspect(event, false, 4, false)}
`, + + `
Error trace` + + `
${stackLines.join("\n")}
` + + `
Original payload` + + `
${util.inspect(event, false, 4, false)}
`, "m.mentions": { user_ids: ["@cadence:cadence.moe"] } diff --git a/notes.md b/notes.md index 7383d3e..aa9066d 100644 --- a/notes.md +++ b/notes.md @@ -1,5 +1,27 @@ # d2m +## Known issues + +- m->d attachments do not work +- m->d edits do not work +- m->d spoilers do not work +- d->m support the rest of the attachments by reading the matrix spec instead of the current approach of whitelisting mime types +- d->m emojis do not work at all (inline chat, single emoji size, reactions, bridged state) +- m->d code blocks have slightly too much spacing +- m->d some reactions don't work because of the variation selector +- <--> check whether I implemented 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 + - 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! + - solution part 3: revisit the permissions to add newly available rooms and to close newly inaccessible rooms +- consider a way to jump to a timestamp by making up a discord snowflake. practical? helpful? +- clean up and write documentation to selfhost +- pluralkit considerations for artemis +- consider whether to use nested spaces for channel categories and threads + +## Mapping + Remember that a discord message may be transformed to multiple matrix messages. A database will be used to store the discord id to matrix event id mapping. Table columns: