Fix membership parsing.

The spec requires the membership status to be inside of the content,
even though sometimes it's outside of it as well.
This commit is contained in:
poljar (Damir Jelić) 2018-02-28 19:39:13 +01:00
parent 0f08584744
commit 97dbda95a7

View file

@ -121,14 +121,14 @@ class RoomInfo():
@staticmethod @staticmethod
def _membership_from_dict(event_dict): def _membership_from_dict(event_dict):
if (event_dict["membership"] not in [ if (event_dict["content"]["membership"] not in [
"invite", "join", "knock", "leave", "ban" "invite", "join", "knock", "leave", "ban"
]): ]):
raise ValueError raise ValueError
if event_dict["membership"] == "join": if event_dict["content"]["membership"] == "join":
return RoomMemberJoin.from_dict(event_dict) return RoomMemberJoin.from_dict(event_dict)
elif event_dict["membership"] == "leave": elif event_dict["content"]["membership"] == "leave":
return RoomMemberLeave.from_dict(event_dict) return RoomMemberLeave.from_dict(event_dict)
return None return None