diff --git a/lib/src/client.dart b/lib/src/client.dart index f66ac06..8f7a396 100644 --- a/lib/src/client.dart +++ b/lib/src/client.dart @@ -77,7 +77,14 @@ class Client { Database database; - Client(this.clientName, {this.debug = false, this.database}) { + bool enableE2eeRecovery; + + /// Create a client + /// clientName = unique identifier of this client + /// debug: Print debug output? + /// database: The database instance to use + /// enableE2eeRecovery: Enable additional logic to try to recover from bad e2ee sessions + Client(this.clientName, {this.debug = false, this.database, this.enableE2eeRecovery = false}) { onLoginStateChanged.stream.listen((loginState) { print('LoginState: ${loginState.toString()}'); }); diff --git a/lib/src/room.dart b/lib/src/room.dart index 18a9b7d..8b80e55 100644 --- a/lib/src/room.dart +++ b/lib/src/room.dart @@ -1814,7 +1814,7 @@ class Room { final session = await client.database.getDbInboundGroupSession(client.id, id, sessionId); if (session == null) { // no session found, let's request it! - if (!_requestedSessionIds.contains(sessionId) && senderKey != null) { + if (client.enableE2eeRecovery && !_requestedSessionIds.contains(sessionId) && senderKey != null) { unawaited(requestSessionKey(sessionId, senderKey)); _requestedSessionIds.add(sessionId); } @@ -1876,7 +1876,7 @@ class Room { decryptedPayload = json.decode(decryptResult.plaintext); } catch (exception) { // alright, if this was actually by our own outbound group session, we might as well clear it - if ((_outboundGroupSession?.session_id() ?? '') == event.content['session_id']) { + if (client.enableE2eeRecovery && (_outboundGroupSession?.session_id() ?? '') == event.content['session_id']) { clearOutboundGroupSession(wipe: true); } if (exception.toString() == DecryptError.UNKNOWN_SESSION) {