From 865b2f6b7f0d2f6e5e9ce3dacfe6372942668431 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Joann=20M=C3=B5ndresku?= <joann@cernodile.com>
Date: Tue, 25 May 2021 13:15:51 +0300
Subject: [PATCH] Inline replies Discord->Matrix

---
 src/bot.ts | 14 ++++++++++++++
 1 file changed, 14 insertions(+)

diff --git a/src/bot.ts b/src/bot.ts
index f5d563a..4346ff4 100644
--- a/src/bot.ts
+++ b/src/bot.ts
@@ -1107,6 +1107,20 @@ export class DiscordBot {
                     formatted_body: result.formattedBody,
                     msgtype: result.msgtype,
                 };
+                if (msg.reference) {
+                    const storeEvent = await this.store.Get(DbEvent, {discord_id: msg.reference?.messageID})
+                    if (storeEvent && storeEvent.Result)
+                    {
+                        while(storeEvent.Next())
+                        {
+                            sendContent["m.relates_to"] = {
+                                "m.in_reply_to": {
+                                    event_id: storeEvent.MatrixId.split(";")[0]
+                                }
+                            };
+                        }
+                    }
+                }
                 if (editEventId) {
                     sendContent.body = `* ${result.body}`;
                     sendContent.formatted_body = `* ${result.formattedBody}`;
-- 
GitLab