Compare commits

..

No commits in common. "9fbef15ad1d922199aa70dfed659eda79ccf64da" and "ef15c850dd67e0196ab52cf282d24fe58b6faadc" have entirely different histories.

3 changed files with 5 additions and 6 deletions

View file

@ -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)
}

View file

@ -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

View file

@ -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