From d36d2107a9f1a48f4bc8bef5765b31a7113e8fb5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Damir=20Jeli=C4=87?= Date: Fri, 5 Apr 2019 18:35:54 +0200 Subject: [PATCH] client: Skip unknown rooms while decrypting. This fixes a crash but the real reason why the room is unknown for pantalaimons client is if the other sync stream is ahead of pantalaimons. This will end up in undecryptable messages unless the client waits for pantalaimon to finish its own sync. This closes #11. --- pantalaimon/client.py | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/pantalaimon/client.py b/pantalaimon/client.py index ad5d18f..24ae40f 100644 --- a/pantalaimon/client.py +++ b/pantalaimon/client.py @@ -119,10 +119,14 @@ class PantaClient(AsyncClient): Returns the json response with decrypted events. """ for room_id, room_dict in body["rooms"]["join"].items(): - if not self.rooms[room_id].encrypted: - logger.info("Room {} is not encrypted skipping...".format( - self.rooms[room_id].display_name - )) + try: + if not self.rooms[room_id].encrypted: + logger.info("Room {} is not encrypted skipping...".format( + self.rooms[room_id].display_name + )) + continue + except KeyError: + logger.info("Unknown room {} skipping...".format(room_id)) continue for event in room_dict["timeline"]["events"]: