Implement device renaming

This commit is contained in:
miruka
2020-06-25 12:11:11 -04:00
parent 3001131ffa
commit 51327d810b
3 changed files with 25 additions and 1 deletions

View File

@@ -1258,7 +1258,7 @@ class MatrixClient(nio.AsyncClient):
async def devices_info(self) -> List[Dict[str, Any]]:
"""Get list of devices and their info for our user."""
"""Get sorted list of devices and their info for our user."""
def get_type(device_id: str) -> str:
# Return "current", "verified", "blacklisted", "ignored" or "unset"
@@ -1301,6 +1301,16 @@ class MatrixClient(nio.AsyncClient):
)
async def rename_device(self, device_id: str, name: str) -> bool:
"""Rename one of our device, return `False` if it doesn't exist."""
try:
await self.update_device(device_id, {"display_name": name})
return True
except MatrixNotFound:
return False
# Functions to register/modify data into models
async def update_account_unread_counts(self) -> None: