Fix m->d then d->m reactions not merging
This commit is contained in:
@@ -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
|
||||
}
|
||||
|
||||
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user