diff --git a/src/matrixeventprocessor.ts b/src/matrixeventprocessor.ts index d3ff2effb7e118535ab6fff5ae2b45e1923e5f07..c76d146f390dfed4f3a37d87f4796b7a6d93daf8 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 21f5c338c3b42ddbf655fb6b347512b4b026fbad..656c7a55253a0aa503e034acb93809b68d252477 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();