From 3f187e81077a4c0032248b3046ea73e044d6f8df Mon Sep 17 00:00:00 2001 From: Cadence Ember Date: Sat, 19 Aug 2023 18:40:01 +1200 Subject: [PATCH] see how this different reactions format goes... --- d2m/actions/add-reaction.js | 2 +- d2m/actions/edit-message.js | 3 --- m2d/actions/add-reaction.js | 8 +++++--- 3 files changed, 6 insertions(+), 7 deletions(-) diff --git a/d2m/actions/add-reaction.js b/d2m/actions/add-reaction.js index 49afca9..b46af59 100644 --- a/d2m/actions/add-reaction.js +++ b/d2m/actions/add-reaction.js @@ -22,7 +22,7 @@ async function addReaction(data) { assert.equal(typeof parentID, "string") const roomID = await createRoom.ensureRoom(data.channel_id) 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": { rel_type: "m.annotation", event_id: parentID, diff --git a/d2m/actions/edit-message.js b/d2m/actions/edit-message.js index 8e8c838..fa152cf 100644 --- a/d2m/actions/edit-message.js +++ b/d2m/actions/edit-message.js @@ -12,10 +12,7 @@ const api = sync.require("../../matrix/api") * @param {import("discord-api-types/v10").APIGuild} 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) - console.log("making these changes:") - console.dir({eventsToRedact, eventsToReplace, eventsToSend}, {depth: null}) // 1. Replace all the things. for (const {oldID, newContent} of eventsToReplace) { diff --git a/m2d/actions/add-reaction.js b/m2d/actions/add-reaction.js index d259ddb..68828dd 100644 --- a/m2d/actions/add-reaction.js +++ b/m2d/actions/add-reaction.js @@ -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 let emoji = event.content["m.relates_to"].key // TODO: handle custom text or emoji reactions - emoji = encodeURIComponent(emoji) - emoji = emoji.replace(/%EF%B8%8F/g, "") + let encoded = encodeURIComponent(emoji) + 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