Fix past member events affecting actual room state

This commit is contained in:
miruka 2020-05-20 09:05:36 -04:00
parent 7719df0135
commit 42b62377ab

View File

@ -355,9 +355,11 @@ class NioCallbacks:
async def onRoomMemberEvent(self, room, ev) -> None: 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) 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) await self.client.remove_member(room, user_id=ev.state_key)
type_and_content = await self.process_room_member_event(room, ev) type_and_content = await self.process_room_member_event(room, ev)