Skip to content

Commit

Permalink
Fix finding matrix room that is already joined (home-assistant#67967)
Browse files Browse the repository at this point in the history
After some debugging, it seems room.canonical_alias contains the
room alias that matches the room_id_or_alias value but is not
contained in room.aliases (which is empty). As a result, the
matrix component thought the room wasn't alread joined, joins
again, and this replaces the previous room which had the listener.
This resulted in the component callback not being called for new
messages in the room.

This fixes home-assistant#66372
  • Loading branch information
antlarr authored Mar 15, 2022
1 parent 65c670c commit 2aaeb1f
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion homeassistant/components/matrix/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,10 @@ def _join_or_get_room(self, room_id_or_alias):
room.update_aliases()
self._aliases_fetched_for.add(room.room_id)

if room_id_or_alias in room.aliases:
if (
room_id_or_alias in room.aliases
or room_id_or_alias == room.canonical_alias
):
_LOGGER.debug(
"Already in room %s (known as %s)", room.room_id, room_id_or_alias
)
Expand Down

0 comments on commit 2aaeb1f

Please sign in to comment.