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)