From dc92dc0b69492b52fe477cc1f946a8c9bb884093 Mon Sep 17 00:00:00 2001 From: Cadence Ember Date: Tue, 10 Oct 2023 11:29:27 +1300 Subject: [PATCH] Annotate crossposted messages with their origin --- d2m/converters/message-to-event.js | 6 ++++++ d2m/converters/message-to-event.test.js | 12 ++++++++++++ 2 files changed, 18 insertions(+) diff --git a/d2m/converters/message-to-event.js b/d2m/converters/message-to-event.js index 3241582..09ac39a 100644 --- a/d2m/converters/message-to-event.js +++ b/d2m/converters/message-to-event.js @@ -194,6 +194,12 @@ async function messageToEvent(message, guild, options = {}, di) { html = "* " + html } + const flags = message.flags || 0 + if (flags & 2) { + body = `[🔀 ${message.author.username}]\n` + body + html = `🔀 ${message.author.username}
` + html + } + // Fallback body/formatted_body for replies // This branch is optional - do NOT change anything apart from the reply fallback, since it may not be run if (repliedToEventRow && options.includeReplyFallback !== false) { diff --git a/d2m/converters/message-to-event.test.js b/d2m/converters/message-to-event.test.js index 715aa5d..19f0111 100644 --- a/d2m/converters/message-to-event.test.js +++ b/d2m/converters/message-to-event.test.js @@ -490,3 +490,15 @@ test("message2event: emoji triple long name", async t => { + ':brillillillilliant_move:' }]) }) + +test("message2event: crossposted announcements say where they are crossposted from", async t => { + const events = await messageToEvent(data.special_message.crosspost_announcement, data.guild.general, {}) + t.deepEqual(events, [{ + $type: "m.room.message", + "m.mentions": {}, + msgtype: "m.text", + body: "[🔀 Chewey Bot Official Server #announcements]\nAll text based commands are now inactive on Chewey Bot\nTo continue using commands you'll need to use them as slash commands", + format: "org.matrix.custom.html", + formatted_body: "🔀 Chewey Bot Official Server #announcements
All text based commands are now inactive on Chewey Bot
To continue using commands you'll need to use them as slash commands" + }]) +})