Skip to content
Extraits de code Groupes Projets
Valider cb8ffd14 rédigé par Half-Shot's avatar Half-Shot
Parcourir les fichiers

Fix event handler tests

parent 3de54156
Aucune branche associée trouvée
Aucune étiquette associée trouvée
Aucune requête de fusion associée trouvée
...@@ -365,7 +365,9 @@ export class MatrixEventProcessor { ...@@ -365,7 +365,9 @@ export class MatrixEventProcessor {
// Try to get the event. // Try to get the event.
try { try {
const sourceEvent = (await intent.underlyingClient.getEvent(event.room_id, eventId)) as IMatrixEvent; 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; const replyEmbed = (await this.EventToEmbed(sourceEvent, channel, false)).messageEmbed;
// if we reply to a discord member, ping them! // if we reply to a discord member, ping them!
...@@ -389,7 +391,6 @@ export class MatrixEventProcessor { ...@@ -389,7 +391,6 @@ export class MatrixEventProcessor {
} }
return replyEmbed; return replyEmbed;
} catch (ex) { } catch (ex) {
console.log(ex);
log.warn("Failed to handle reply, showing a unknown embed:", ex); log.warn("Failed to handle reply, showing a unknown embed:", ex);
} }
// For some reason we failed to get the event, so using fallback. // For some reason we failed to get the event, so using fallback.
......
...@@ -725,9 +725,9 @@ This is the reply`, ...@@ -725,9 +725,9 @@ This is the reply`,
type: "m.room.message", type: "m.room.message",
} as IMatrixEvent, mockChannel as any); } as IMatrixEvent, mockChannel as any);
expect(result!.description).to.be.equal("Reply with unknown content"); expect(result!.description).to.be.equal("Reply with unknown content");
expect(result!.author!.name).to.be.equal("Doggo!"); expect(result!.author!.name).to.be.equal("Unknown");
expect(result!.author!.icon_url).to.be.equal("https://fakeurl.com"); expect(result!.author!.icon_url).to.be.undefined;
expect(result!.author!.url).to.be.equal("https://matrix.to/#/@doggo:localhost"); expect(result!.author!.url).to.be.undefined;
}); });
it("should add the reply time", async () => { it("should add the reply time", async () => {
const {processor} = createMatrixEventProcessor(); const {processor} = createMatrixEventProcessor();
......
0% Chargement en cours ou .
You are about to add 0 people to the discussion. Proceed with caution.
Veuillez vous inscrire ou vous pour commenter