Skip to content

Commit

Permalink
Handle all m.room.aliases, not only first in _process_state_event too
Browse files Browse the repository at this point in the history
  • Loading branch information
Pavel Kardash committed Sep 3, 2018
1 parent 748c65b commit 8ed4dfa
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
5 changes: 3 additions & 2 deletions matrix_client/room.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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":
Expand Down
6 changes: 3 additions & 3 deletions test/client_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ def test_state_event():

room.name = False
room.topic = False
room.aliases = False
room.aliases = []

ev = {
"type": "m.room.name",
Expand All @@ -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"
Expand Down

0 comments on commit 8ed4dfa

Please sign in to comment.