Fix m->d then d->m reactions not merging

This commit is contained in:
Cadence Ember
2025-06-16 22:50:34 +12:00
parent edf60bcd2d
commit 2c15468c22
7 changed files with 17 additions and 7 deletions
+6 -2
View File
@@ -8,9 +8,10 @@ const file = sync.require("../../matrix/file")
/**
* @param {import("discord-api-types/v10").APIEmoji} emoji
* @param {string} message_id
* @returns {Promise<string>}
*/
async function emojiToKey(emoji) {
async function emojiToKey(emoji, message_id) {
let key
if (emoji.id) {
// Custom emoji
@@ -30,7 +31,10 @@ async function emojiToKey(emoji) {
// Default emoji
const name = emoji.name
assert(name)
key = name
// If the reaction was used on Matrix already, it might be using a different arrangement of Variation Selector 16 characters.
// We'll use the same arrangement that was originally used, otherwise a duplicate of the emoji will appear as a separate reaction.
const originalEncoding = select("reaction", "original_encoding", {message_id, encoded_emoji: encodeURIComponent(name)}).pluck().get()
key = originalEncoding || name
}
return key
}
+1 -1
View File
@@ -401,7 +401,7 @@ async function messageToEvent(message, guild, options = {}, di) {
const id = match[3]
const name = match[2]
const animated = !!match[1]
return emojiToKey.emojiToKey({id, name, animated}) // Register the custom emoji if needed
return emojiToKey.emojiToKey({id, name, animated}, message.id) // Register the custom emoji if needed
}))
async function transformParsedVia(parsed) {