From 8ed4dfa4e5c1c48858566c83c3eb85a656ba234e Mon Sep 17 00:00:00 2001 From: Pavel Kardash Date: Mon, 3 Sep 2018 10:25:28 +0300 Subject: [PATCH] Handle all m.room.aliases, not only first in _process_state_event too --- matrix_client/room.py | 5 +++-- test/client_test.py | 6 +++--- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/matrix_client/room.py b/matrix_client/room.py index 4add0059..0bac9e50 100644 --- a/matrix_client/room.py +++ b/matrix_client/room.py @@ -454,7 +454,6 @@ def update_aliases(self): Returns: boolean: True if the aliases changed, False if not """ - response = None try: response = self.client.api.get_room_state(self.room_id) except MatrixRequestError: @@ -652,7 +651,9 @@ def _process_state_event(self, state_event): elif etype == "m.room.topic": self.topic = econtent.get("topic") elif etype == "m.room.aliases": - self.aliases = econtent.get("aliases") + for alias in econtent.get("aliases", []): + if alias not in self.aliases: + self.aliases.append(alias) elif etype == "m.room.join_rules": self.invite_only = econtent["join_rule"] == "invite" elif etype == "m.room.guest_access": diff --git a/test/client_test.py b/test/client_test.py index c5884924..c68baae9 100644 --- a/test/client_test.py +++ b/test/client_test.py @@ -95,7 +95,7 @@ def test_state_event(): room.name = False room.topic = False - room.aliases = False + room.aliases = [] ev = { "type": "m.room.name", @@ -119,12 +119,12 @@ def test_state_event(): ev["type"] = "m.room.aliases" room._process_state_event(ev) - assert room.aliases is None + assert room.aliases == [] aliases = ["#foo:matrix.org", "#bar:matrix.org"] ev["content"]["aliases"] = aliases room._process_state_event(ev) - assert room.aliases is aliases + assert room.aliases == aliases # test member join event ev["type"] = "m.room.member"