From 42b62377abb9065371a01540d3577c6f35f23f41 Mon Sep 17 00:00:00 2001 From: miruka Date: Wed, 20 May 2020 09:05:36 -0400 Subject: [PATCH] Fix past member events affecting actual room state --- src/backend/nio_callbacks.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/backend/nio_callbacks.py b/src/backend/nio_callbacks.py index d2808383..05d9d484 100644 --- a/src/backend/nio_callbacks.py +++ b/src/backend/nio_callbacks.py @@ -355,9 +355,11 @@ class NioCallbacks: async def onRoomMemberEvent(self, room, ev) -> None: - if ev.membership in ("invite", "join") and ev.state_key in room.users: + # The event can be a past event, don't trust it to update the model + # room's current state. + if ev.state_key in room.users: await self.client.add_member(room, user_id=ev.state_key) - elif ev.membership in ("left", "ban"): + else: await self.client.remove_member(room, user_id=ev.state_key) type_and_content = await self.process_room_member_event(room, ev)