make e2ee recovery logic optional
This commit is contained in:
parent
11d788b68f
commit
a3fc73dfc1
|
@ -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()}');
|
||||
});
|
||||
|
|
|
@ -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) {
|
||||
|
|
Loading…
Reference in a new issue