diff --git a/src/matrix/Client.js b/src/matrix/Client.js index 5f6d5ea1..f070d24c 100644 --- a/src/matrix/Client.js +++ b/src/matrix/Client.js @@ -386,10 +386,21 @@ export class Client { return !this._reconnector; } - logout() { + startLogout(sessionId) { return this._platform.logger.run("logout", async log => { + this._sessionId = sessionId; + log.set("id", this._sessionId); + const sessionInfo = await this._platform.sessionInfoStorage.get(this._sessionId); + if (!sessionInfo) { + throw new Error(`Could not find session for id ${this._sessionId}`); + } try { - await this._session?.logout(log); + const hsApi = new HomeServerApi({ + homeserver: sessionInfo.homeServer, + accessToken: sessionInfo.accessToken, + request: this._platform.request + }); + await hsApi.logout({log}).response(); } catch (err) {} await this.deleteSession(log); }); diff --git a/src/matrix/Session.js b/src/matrix/Session.js index ddb3fdb5..8ccc71cc 100644 --- a/src/matrix/Session.js +++ b/src/matrix/Session.js @@ -109,11 +109,6 @@ export class Session { return this._sessionInfo.userId; } - /** @internal call Client.logout instead */ - async logout(log = undefined) { - await this._hsApi.logout({log}).response(); - } - // called once this._e2eeAccount is assigned _setupEncryption() { // TODO: this should all go in a wrapper in e2ee/ that is bootstrapped by passing in the account