see how this different reactions format goes...
This commit is contained in:
parent
0fc8e68f15
commit
3f187e8107
3 changed files with 6 additions and 7 deletions
|
@ -22,7 +22,7 @@ async function addReaction(data) {
|
||||||
assert.equal(typeof parentID, "string")
|
assert.equal(typeof parentID, "string")
|
||||||
const roomID = await createRoom.ensureRoom(data.channel_id)
|
const roomID = await createRoom.ensureRoom(data.channel_id)
|
||||||
const senderMxid = await registerUser.ensureSimJoined(user, roomID)
|
const senderMxid = await registerUser.ensureSimJoined(user, roomID)
|
||||||
const eventID = api.sendEvent(roomID, "m.reaction", {
|
const eventID = await api.sendEvent(roomID, "m.reaction", {
|
||||||
"m.relates_to": {
|
"m.relates_to": {
|
||||||
rel_type: "m.annotation",
|
rel_type: "m.annotation",
|
||||||
event_id: parentID,
|
event_id: parentID,
|
||||||
|
|
|
@ -12,10 +12,7 @@ const api = sync.require("../../matrix/api")
|
||||||
* @param {import("discord-api-types/v10").APIGuild} guild
|
* @param {import("discord-api-types/v10").APIGuild} guild
|
||||||
*/
|
*/
|
||||||
async function editMessage(message, guild) {
|
async function editMessage(message, guild) {
|
||||||
console.log(`*** applying edit for message ${message.id} in channel ${message.channel_id}`)
|
|
||||||
const {roomID, eventsToRedact, eventsToReplace, eventsToSend, senderMxid} = await editToChanges.editToChanges(message, guild, api)
|
const {roomID, eventsToRedact, eventsToReplace, eventsToSend, senderMxid} = await editToChanges.editToChanges(message, guild, api)
|
||||||
console.log("making these changes:")
|
|
||||||
console.dir({eventsToRedact, eventsToReplace, eventsToSend}, {depth: null})
|
|
||||||
|
|
||||||
// 1. Replace all the things.
|
// 1. Replace all the things.
|
||||||
for (const {oldID, newContent} of eventsToReplace) {
|
for (const {oldID, newContent} of eventsToReplace) {
|
||||||
|
|
|
@ -18,10 +18,12 @@ async function addReaction(event) {
|
||||||
// no need to sync the matrix member to the other side. but if I did need to, this is where I'd do it
|
// no need to sync the matrix member to the other side. but if I did need to, this is where I'd do it
|
||||||
|
|
||||||
let emoji = event.content["m.relates_to"].key // TODO: handle custom text or emoji reactions
|
let emoji = event.content["m.relates_to"].key // TODO: handle custom text or emoji reactions
|
||||||
emoji = encodeURIComponent(emoji)
|
let encoded = encodeURIComponent(emoji)
|
||||||
emoji = emoji.replace(/%EF%B8%8F/g, "")
|
let encodedTrimmed = encoded.replace(/%EF%B8%8F/g, "")
|
||||||
|
|
||||||
return discord.snow.channel.createReaction(channelID, messageID, emoji)
|
console.log("add reaction from matrix:", emoji, encoded, encodedTrimmed)
|
||||||
|
|
||||||
|
return discord.snow.channel.createReaction(channelID, messageID, encoded)
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports.addReaction = addReaction
|
module.exports.addReaction = addReaction
|
||||||
|
|
Loading…
Reference in a new issue