fix m<->d ™®© reactions #111

Open
mschae wants to merge 1 commit from mschae/out-of-your-element:tm-reactions into main
2 changed files with 21 additions and 1 deletions
Showing only changes of commit e5a4a28771 - Show all commits

fix m<->d ™®© reactions

mini-bomba 2026-11-15 02:11:54 +01:00
No known key found for this signature in database
GPG key ID: 30F8B138B4794886

View file

@ -34,7 +34,20 @@ async function emojiToKey(emoji, message_id) {
// If the reaction was used on Matrix already, it might be using a different arrangement of Variation Selector 16 characters. // 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. // 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() const originalEncoding = select("reaction", "original_encoding", {message_id, encoded_emoji: encodeURIComponent(name)}).pluck().get()
key = originalEncoding || name if (originalEncoding) {
key = originalEncoding
} else {
key = name
// ™, ® and © are weird, because they exist in two forms: emoji and text...
// ... and discord prefers the text version
// on m->d we're forced to convert emoji versions to text
// the branch above already handles the case where the initial reaction was on matrix,
// but in case that it's on discord, convert the text to a proper emoji before bridging it
if (key === "™") key = "™️"
if (key === "®") key = "®️"
if (key === "©") key = "©️"
}
} }
return key return key
} }

View file

@ -43,6 +43,13 @@ async function encodeDefaultEmoji(input) {
const emojis = await emojisp const emojis = await emojisp
const encoded = encodeURIComponent(input) const encoded = encodeURIComponent(input)
// ™, ® and © are weird, because they exist in two forms: emoji and text...
// ... and discord prefers the text version
// so if someone reacts with the emoji version, convert it to the text version discord wants
if (input === "™️") return encodeURIComponent("™")
if (input === "®️") return encodeURIComponent("®")
if (input === "©️") return encodeURIComponent("©")
// Best case scenario: they reacted with an exact replica of a valid emoji. // Best case scenario: they reacted with an exact replica of a valid emoji.
if (emojis.includes(input)) return encoded if (emojis.includes(input)) return encoded