From a5d170eb8fa53b6f96f66e03d69113e9d4f831f1 Mon Sep 17 00:00:00 2001 From: Cadence Ember Date: Fri, 6 Oct 2023 16:58:18 +1300 Subject: [PATCH 1/3] Choosing first event as primary part = 0 is fine --- d2m/actions/send-message.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/d2m/actions/send-message.js b/d2m/actions/send-message.js index 9befbf6..ab5b6c6 100644 --- a/d2m/actions/send-message.js +++ b/d2m/actions/send-message.js @@ -46,7 +46,10 @@ async function sendMessage(message, guild) { const eventID = await api.sendEvent(roomID, eventType, eventWithoutType, senderMxid, useTimestamp) db.prepare("INSERT INTO event_message (event_id, event_type, event_subtype, message_id, part, source) VALUES (?, ?, ?, ?, ?, 1)").run(eventID, eventType, event.msgtype || null, message.id, eventPart) // source 1 = discord - eventPart = 1 // TODO: use more intelligent algorithm to determine whether primary or supporting + // The primary event is part = 0 and has the most important and distinct information. It is used to provide reply previews, be pinned, and possibly future uses. + // The first event is chosen to be the primary part because it is usually the message text content and is more likely to be distinct. + // For example, "Reply to 'this meme made me think of you'" is more useful than "Replied to image". + eventPart = 1 eventIDs.push(eventID) } From a925750254a6645e493d0c46334a74aa0b864d3b Mon Sep 17 00:00:00 2001 From: Cadence Ember Date: Fri, 6 Oct 2023 16:58:44 +1300 Subject: [PATCH 2/3] Handling custom emoji reactions is already done --- m2d/actions/add-reaction.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/m2d/actions/add-reaction.js b/m2d/actions/add-reaction.js index eb12bd4..e6a94d9 100644 --- a/m2d/actions/add-reaction.js +++ b/m2d/actions/add-reaction.js @@ -19,7 +19,7 @@ async function addReaction(event) { const messageID = select("event_message", "message_id", {event_id: event.content["m.relates_to"].event_id, part: 0}).pluck().get() // 0 = primary if (!messageID) return // Nothing can be done if the parent message was never bridged. - const key = event.content["m.relates_to"].key // TODO: handle custom text or emoji reactions + const key = event.content["m.relates_to"].key const discordPreferredEncoding = emoji.encodeEmoji(key, event.content.shortcode) if (!discordPreferredEncoding) return From 9fbef15ad1d922199aa70dfed659eda79ccf64da Mon Sep 17 00:00:00 2001 From: Cadence Ember Date: Fri, 6 Oct 2023 17:00:21 +1300 Subject: [PATCH 3/3] The function argument is good enough --- matrix/file.js | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/matrix/file.js b/matrix/file.js index 626a1ad..f0ee29a 100644 --- a/matrix/file.js +++ b/matrix/file.js @@ -21,13 +21,11 @@ function _removeExpiryParams(url) { } /** - * @param {string} path + * @param {string} path or full URL if it's not a Discord CDN file */ async function uploadDiscordFileToMxc(path) { let url if (path.startsWith("http")) { - // TODO: this is cheating to make seed.js easier. due a refactor or a name change since it's not soley for discord? - // possibly could be good to save non-discord external URLs under a user-specified key rather than simply using the url? url = path } else { url = DISCORD_IMAGES_BASE + path