Skip to content

Commit

Permalink
Fix error being raised on no DM rooms
Browse files Browse the repository at this point in the history
  • Loading branch information
nexy7574 committed Feb 8, 2024
1 parent b96f61c commit b82ef02
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/niobot/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -737,6 +737,9 @@ async def get_dm_rooms(
raise RuntimeError("You must have matrix-nio version 0.24.0 or later to use this feature.")
result = await self.list_direct_rooms()
if isinstance(result, nio.DirectRoomsErrorResponse):
if result.status_code == "M_NOT_FOUND":
# No DM rooms for this account are known
return {} if user is None else []
raise GenericMatrixError("Failed to get DM rooms", response=result)
if user:
user_id = self._get_id(user)
Expand Down

0 comments on commit b82ef02

Please sign in to comment.