Use nio's new restore_login() method
This commit is contained in:
parent
e611f89fe3
commit
6d8980bcb3
2
TODO.md
2
TODO.md
|
@ -176,8 +176,6 @@
|
|||
|
||||
## Backend
|
||||
|
||||
- Use new nio `AsyncClient.restore_login()`
|
||||
|
||||
- Better config file format
|
||||
|
||||
- Prevent starting multiple client instances, causes problems with E2E DB
|
||||
|
|
|
@ -233,8 +233,7 @@ class Backend:
|
|||
"""Create and register a `MatrixClient` with known account details."""
|
||||
|
||||
client = MatrixClient(
|
||||
backend=self,
|
||||
user=user_id, homeserver=homeserver, device_id=device_id,
|
||||
self, user=user_id, homeserver=homeserver, device_id=device_id,
|
||||
)
|
||||
|
||||
self.clients[user_id] = client
|
||||
|
|
|
@ -292,19 +292,19 @@ class MatrixClient(nio.AsyncClient):
|
|||
|
||||
async def resume(
|
||||
self,
|
||||
user_id: str,
|
||||
token: str,
|
||||
device_id: str,
|
||||
state: str = "online",
|
||||
status_msg: str = "",
|
||||
user_id: str,
|
||||
access_token: str,
|
||||
device_id: str,
|
||||
state: str = "online",
|
||||
status_msg: str = "",
|
||||
) -> None:
|
||||
"""Login to the server using an existing access token."""
|
||||
"""Restore a previous login to the server with a saved access token."""
|
||||
|
||||
response = nio.LoginResponse(user_id, device_id, token)
|
||||
account = self.models["accounts"][user_id]
|
||||
await self.receive_response(response)
|
||||
self.restore_login(user_id, device_id, access_token)
|
||||
|
||||
account = self.models["accounts"][user_id]
|
||||
self._presence = "offline" if state == "invisible" else state
|
||||
|
||||
account.set_fields(
|
||||
presence=Presence.State(state), status_msg=status_msg,
|
||||
)
|
||||
|
|
Loading…
Reference in New Issue
Block a user