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
|
## Backend
|
||||||
|
|
||||||
- Use new nio `AsyncClient.restore_login()`
|
|
||||||
|
|
||||||
- Better config file format
|
- Better config file format
|
||||||
|
|
||||||
- Prevent starting multiple client instances, causes problems with E2E DB
|
- 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."""
|
"""Create and register a `MatrixClient` with known account details."""
|
||||||
|
|
||||||
client = MatrixClient(
|
client = MatrixClient(
|
||||||
backend=self,
|
self, user=user_id, homeserver=homeserver, device_id=device_id,
|
||||||
user=user_id, homeserver=homeserver, device_id=device_id,
|
|
||||||
)
|
)
|
||||||
|
|
||||||
self.clients[user_id] = client
|
self.clients[user_id] = client
|
||||||
|
|
|
@ -293,18 +293,18 @@ class MatrixClient(nio.AsyncClient):
|
||||||
async def resume(
|
async def resume(
|
||||||
self,
|
self,
|
||||||
user_id: str,
|
user_id: str,
|
||||||
token: str,
|
access_token: str,
|
||||||
device_id: str,
|
device_id: str,
|
||||||
state: str = "online",
|
state: str = "online",
|
||||||
status_msg: str = "",
|
status_msg: str = "",
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Login to the server using an existing access token."""
|
"""Restore a previous login to the server with a saved access token."""
|
||||||
|
|
||||||
|
self.restore_login(user_id, device_id, access_token)
|
||||||
|
|
||||||
response = nio.LoginResponse(user_id, device_id, token)
|
|
||||||
account = self.models["accounts"][user_id]
|
account = self.models["accounts"][user_id]
|
||||||
await self.receive_response(response)
|
|
||||||
|
|
||||||
self._presence = "offline" if state == "invisible" else state
|
self._presence = "offline" if state == "invisible" else state
|
||||||
|
|
||||||
account.set_fields(
|
account.set_fields(
|
||||||
presence=Presence.State(state), status_msg=status_msg,
|
presence=Presence.State(state), status_msg=status_msg,
|
||||||
)
|
)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user