-
-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update get_dm_rooms to use the new list_direct_rooms
- Loading branch information
Showing
3 changed files
with
8 additions
and
44 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,33 +1,8 @@ | ||
# OUTDATED AND NOT USED ANYMORE | ||
# Pull from https://github.com/poljar/matrix-nio/pull/451 temporarily. | ||
from dataclasses import dataclass, field | ||
from typing import Any, Dict, List, Union | ||
|
||
from nio.responses import ErrorResponse, Response | ||
from nio.responses import DirectRoomsErrorResponse, DirectRoomsResponse | ||
|
||
__all__ = ( | ||
"DirectRoomsErrorResponse", | ||
"DirectRoomsResponse", | ||
) | ||
|
||
|
||
class DirectRoomsErrorResponse(ErrorResponse): | ||
pass | ||
|
||
|
||
@dataclass | ||
class DirectRoomsResponse(Response): | ||
"""A response containing a list of direct rooms. | ||
Attributes: | ||
rooms (List[str]): The rooms joined by the account. | ||
""" | ||
|
||
rooms: Dict[str, List[str]] = field() | ||
|
||
@classmethod | ||
def from_dict( | ||
cls, | ||
parsed_dict: Dict[Any, Any], | ||
) -> Union["DirectRoomsResponse", DirectRoomsErrorResponse]: | ||
if parsed_dict.get("errcode") is not None: | ||
return DirectRoomsErrorResponse.from_dict(parsed_dict) | ||
return cls(parsed_dict) | ||
) |