Skip to content
Extraits de code Groupes Projets
Non vérifiée Valider 4e35a348 rédigé par Will Hunt's avatar Will Hunt Validation de GitHub
Parcourir les fichiers

Merge pull request #352 from Half-Shot/soru/event_msg

make logging of events less verbose
parents 8c63469c e2df4065
Aucune branche associée trouvée
Aucune étiquette associée trouvée
Aucune requête de fusion associée trouvée
......@@ -118,7 +118,7 @@ export class MatrixRoomHandler {
const event = request.getData() as IMatrixEvent;
if (event.unsigned.age > AGE_LIMIT) {
log.warn(`Skipping event due to age ${event.unsigned.age} > ${AGE_LIMIT}`);
throw new Error("Event too old");
return;
}
if (event.type === "m.room.member" && event.content!.membership === "invite") {
await this.HandleInvite(event);
......@@ -164,7 +164,7 @@ export class MatrixRoomHandler {
} else {
log.verbose("Got non m.room.message event");
}
throw new Error("Event not processed by bridge");
log.verbose("Event not processed by bridge");
}
public async HandleEncryptionWarning(roomId: string): Promise<void> {
......
......@@ -210,27 +210,18 @@ describe("MatrixRoomHandler", () => {
it("should reject old events", async () => {
const AGE = 900001; // 15 * 60 * 1000
const handler = createRH();
try {
await handler.OnEvent(buildRequest({unsigned: {age: AGE}}), null);
throw new Error("didn't fail");
} catch (e) {
expect(e.message).to.not.equal("didn't fail");
expect(e.message).equals("Event too old");
}
expect(MESSAGE_PROCCESS).equals("");
});
it("should reject un-processable events", async () => {
const AGE = 900000; // 15 * 60 * 1000
const handler = createRH();
try {
// check if nothing is thrown
await handler.OnEvent(buildRequest({
content: {},
type: "m.potato",
unsigned: {age: AGE}}), null);
throw new Error("didn't fail");
} catch (e) {
expect(e.message).to.not.equal("didn't fail");
expect(e.message).equals("Event not processed by bridge");
}
expect(MESSAGE_PROCCESS).equals("");
});
it("should handle invites", async () => {
const handler = createRH();
......@@ -282,14 +273,9 @@ describe("MatrixRoomHandler", () => {
remote: null,
},
};
try {
await handler.OnEvent(buildRequest({
type: "m.room.redaction"}), context);
throw new Error("didn't fail");
} catch (e) {
expect(e.message).to.not.equal("didn't fail");
expect(e.message).equals("Event not processed by bridge");
}
expect(MESSAGE_PROCCESS).equals("");
});
it("should process regular messages", async () => {
const handler = createRH();
......@@ -339,16 +325,11 @@ describe("MatrixRoomHandler", () => {
remote: null,
},
};
try {
await handler.OnEvent(buildRequest({
content: {body: "abc"},
type: "m.room.message",
}), context);
throw new Error("didn't fail");
} catch (e) {
expect(e.message).to.not.equal("didn't fail");
expect(e.message).equals("Event not processed by bridge");
}
expect(MESSAGE_PROCCESS).equals("");
});
it("should process stickers", async () => {
const handler = createRH();
......
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