From 314f37f6402862ee47ecfe275c87a445ee87d7f1 Mon Sep 17 00:00:00 2001 From: Cadence Ember Date: Wed, 11 Feb 2026 11:49:35 +1300 Subject: [PATCH 1/2] Add newline at end of registration to help shells --- src/matrix/read-registration.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/matrix/read-registration.js b/src/matrix/read-registration.js index 9316158..6dc64dd 100644 --- a/src/matrix/read-registration.js +++ b/src/matrix/read-registration.js @@ -22,7 +22,7 @@ function checkRegistration(reg) { /* c8 ignore next 4 */ /** @param {import("../types").AppServiceRegistrationConfig} reg */ function writeRegistration(reg) { - fs.writeFileSync(registrationFilePath, JSON.stringify(reg, null, 2)) + fs.writeFileSync(registrationFilePath, JSON.stringify(reg, null, 2) + "\n") } /** From 6df931f848d01af9f9951d3da8fdd0abdc8452fd Mon Sep 17 00:00:00 2001 From: Cadence Ember Date: Wed, 11 Feb 2026 11:49:45 +1300 Subject: [PATCH 2/2] Check if we got rugpulled while sending --- src/d2m/actions/send-message.js | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/src/d2m/actions/send-message.js b/src/d2m/actions/send-message.js index 283f2ec..eb919bb 100644 --- a/src/d2m/actions/send-message.js +++ b/src/d2m/actions/send-message.js @@ -86,7 +86,19 @@ async function sendMessage(message, channel, guild, row) { const useTimestamp = message["backfill"] ? new Date(message.timestamp).getTime() : undefined const eventID = await api.sendEvent(roomID, eventType, eventWithoutType, senderMxid, useTimestamp) - db.prepare("INSERT INTO event_message (event_id, event_type, event_subtype, message_id, part, reaction_part, source) VALUES (?, ?, ?, ?, ?, ?, 1)").run(eventID, eventType, event.msgtype || null, message.id, part, reactionPart) // source 1 = discord + eventIDs.push(eventID) + + try { + db.prepare("INSERT INTO event_message (event_id, event_type, event_subtype, message_id, part, reaction_part, source) VALUES (?, ?, ?, ?, ?, ?, 1)").run(eventID, eventType, event.msgtype || null, message.id, part, reactionPart) // source 1 = discord + } catch (e) { + // check if we got rugpulled + if (!select("message_room", "message_id", {message_id: message.id}).get()) { + for (const eventID of eventIDs) { + await api.redactEvent(roomID, eventID) + } + return [] + } + } // The primary event is part = 0 and has the most important and distinct information. It is used to provide reply previews, be pinned, and possibly future uses. // The first event is chosen to be the primary part because it is usually the message text content and is more likely to be distinct. @@ -123,8 +135,6 @@ async function sendMessage(message, channel, guild, row) { db.prepare("INSERT INTO event_message (event_id, event_type, event_subtype, message_id, part, reaction_part, source) VALUES (?, ?, ?, ?, ?, ?, 0)").run(eventID, eventType, event.msgtype || null, sentResultsMessage.id, 1, 0) })() } - - eventIDs.push(eventID) } return eventIDs