From cb8ffd149b07c495ceda70d47286c683365130b5 Mon Sep 17 00:00:00 2001
From: Half-Shot <will@half-shot.uk>
Date: Tue, 20 Aug 2019 16:57:18 +0100
Subject: [PATCH] Fix event handler tests

---
 src/matrixeventprocessor.ts       | 5 +++--
 test/test_matrixeventprocessor.ts | 6 +++---
 2 files changed, 6 insertions(+), 5 deletions(-)

diff --git a/src/matrixeventprocessor.ts b/src/matrixeventprocessor.ts
index d3ff2ef..c76d146 100644
--- a/src/matrixeventprocessor.ts
+++ b/src/matrixeventprocessor.ts
@@ -365,7 +365,9 @@ export class MatrixEventProcessor {
         // Try to get the event.
         try {
             const sourceEvent = (await intent.underlyingClient.getEvent(event.room_id, eventId)) as IMatrixEvent;
-            sourceEvent.content!.body = sourceEvent.content!.body  || "Reply with unknown content";
+            if (!sourceEvent || !sourceEvent.content || !sourceEvent.content.body) {
+                throw Error("No content could be found");
+            }
             const replyEmbed = (await this.EventToEmbed(sourceEvent, channel, false)).messageEmbed;
 
             // if we reply to a discord member, ping them!
@@ -389,7 +391,6 @@ export class MatrixEventProcessor {
             }
             return replyEmbed;
         } catch (ex) {
-            console.log(ex);
             log.warn("Failed to handle reply, showing a unknown embed:", ex);
         }
         // For some reason we failed to get the event, so using fallback.
diff --git a/test/test_matrixeventprocessor.ts b/test/test_matrixeventprocessor.ts
index 21f5c33..656c7a5 100644
--- a/test/test_matrixeventprocessor.ts
+++ b/test/test_matrixeventprocessor.ts
@@ -725,9 +725,9 @@ This is the reply`,
                 type: "m.room.message",
             } as IMatrixEvent, mockChannel as any);
             expect(result!.description).to.be.equal("Reply with unknown content");
-            expect(result!.author!.name).to.be.equal("Doggo!");
-            expect(result!.author!.icon_url).to.be.equal("https://fakeurl.com");
-            expect(result!.author!.url).to.be.equal("https://matrix.to/#/@doggo:localhost");
+            expect(result!.author!.name).to.be.equal("Unknown");
+            expect(result!.author!.icon_url).to.be.undefined;
+            expect(result!.author!.url).to.be.undefined;
         });
         it("should add the reply time", async () => {
             const {processor} =  createMatrixEventProcessor();
-- 
GitLab