diff --git a/d2m/actions/send-message.js b/d2m/actions/send-message.js index ab5b6c6..9befbf6 100644 --- a/d2m/actions/send-message.js +++ b/d2m/actions/send-message.js @@ -46,10 +46,7 @@ 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 - // 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 + eventPart = 1 // TODO: use more intelligent algorithm to determine whether primary or supporting eventIDs.push(eventID) } diff --git a/m2d/actions/add-reaction.js b/m2d/actions/add-reaction.js index e6a94d9..eb12bd4 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 + const key = event.content["m.relates_to"].key // TODO: handle custom text or emoji reactions const discordPreferredEncoding = emoji.encodeEmoji(key, event.content.shortcode) if (!discordPreferredEncoding) return diff --git a/matrix/file.js b/matrix/file.js index f0ee29a..626a1ad 100644 --- a/matrix/file.js +++ b/matrix/file.js @@ -21,11 +21,13 @@ function _removeExpiryParams(url) { } /** - * @param {string} path or full URL if it's not a Discord CDN file + * @param {string} path */ 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