Bridge the shortcode as part of reactions
This commit is contained in:
parent
4f807159ba
commit
a396e6f596
3 changed files with 13 additions and 8 deletions
|
@ -50,7 +50,8 @@ async function addReaction(data) {
|
||||||
rel_type: "m.annotation",
|
rel_type: "m.annotation",
|
||||||
event_id: parentID,
|
event_id: parentID,
|
||||||
key
|
key
|
||||||
}
|
},
|
||||||
|
shortcode: `:${data.emoji.name}:`
|
||||||
}, senderMxid)
|
}, senderMxid)
|
||||||
return eventID
|
return eventID
|
||||||
}
|
}
|
||||||
|
|
|
@ -21,16 +21,19 @@ async function addReaction(event) {
|
||||||
let discordPreferredEncoding
|
let discordPreferredEncoding
|
||||||
if (emoji.startsWith("mxc://")) {
|
if (emoji.startsWith("mxc://")) {
|
||||||
// Custom emoji
|
// Custom emoji
|
||||||
const row = select("emoji", ["id", "name"], "WHERE mxc_url = ?").get(emoji)
|
let row = select("emoji", ["id", "name"], "WHERE mxc_url = ?").get(emoji)
|
||||||
if (row) {
|
if (!row && event.content.shortcode) {
|
||||||
// Great, we know exactly what this emoji is!
|
// Use the name to try to find a known emoji with the same name.
|
||||||
discordPreferredEncoding = encodeURIComponent(`${row.name}:${row.id}`)
|
const name = event.content.shortcode.replace(/^:|:$/g, "")
|
||||||
} else {
|
row = select("emoji", ["id", "name"], "WHERE name = ?").get(name)
|
||||||
|
}
|
||||||
|
if (!row) {
|
||||||
// We don't have this emoji and there's no realistic way to just-in-time upload a new emoji somewhere.
|
// We don't have this emoji and there's no realistic way to just-in-time upload a new emoji somewhere.
|
||||||
// We can't try using a known emoji with the same name because we don't even know what the name is. We only have the mxc url.
|
|
||||||
// Sucks!
|
// Sucks!
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
// Cool, we got an exact or a candidate emoji.
|
||||||
|
discordPreferredEncoding = encodeURIComponent(`${row.name}:${row.id}`)
|
||||||
} else {
|
} else {
|
||||||
// Default emoji
|
// Default emoji
|
||||||
// https://github.com/discord/discord-api-docs/issues/2723#issuecomment-807022205 ????????????
|
// https://github.com/discord/discord-api-docs/issues/2723#issuecomment-807022205 ????????????
|
||||||
|
|
3
types.d.ts
vendored
3
types.d.ts
vendored
|
@ -171,7 +171,8 @@ export namespace Event {
|
||||||
rel_type: "m.annotation"
|
rel_type: "m.annotation"
|
||||||
event_id: string // the event that was reacted to
|
event_id: string // the event that was reacted to
|
||||||
key: string // the unicode emoji, mxc uri, or reaction text
|
key: string // the unicode emoji, mxc uri, or reaction text
|
||||||
}
|
},
|
||||||
|
"shortcode"?: string // starts and ends with colons
|
||||||
}
|
}
|
||||||
|
|
||||||
export type Outer_M_Room_Redaction = Outer<{
|
export type Outer_M_Room_Redaction = Outer<{
|
||||||
|
|
Loading…
Reference in a new issue