feat: Replace isSuccessful with canSend

This commit is contained in:
2023-06-17 20:58:33 +02:00
parent 65c0975a77
commit fe2b090ea0
3 changed files with 14 additions and 8 deletions

View File

@@ -630,6 +630,9 @@ class OmemoManager {
ciphertext = null;
}
final successfulEncryptions = Map<String, int>.fromEntries(
stanza.recipientJids.map((jid) => MapEntry(jid, 0)),
);
final encryptionErrors = <String, List<EncryptToJidError>>{};
final addedRatchetKeys = List<RatchetMapKey>.empty(growable: true);
final kex = <RatchetMapKey, OMEMOKeyExchange>{};
@@ -770,6 +773,7 @@ class OmemoManager {
true,
),
);
successfulEncryptions[jid] = successfulEncryptions[jid]! + 1;
} else if (!ratchet.acknowledged) {
// The ratchet as not yet been acked.
// Keep sending the old KEX
@@ -789,6 +793,7 @@ class OmemoManager {
true,
),
);
successfulEncryptions[jid] = successfulEncryptions[jid]! + 1;
} else {
// The ratchet exists and is acked
encryptedKeys.appendOrCreate(
@@ -799,6 +804,7 @@ class OmemoManager {
false,
),
);
successfulEncryptions[jid] = successfulEncryptions[jid]! + 1;
}
}
}
@@ -807,6 +813,7 @@ class OmemoManager {
ciphertext,
encryptedKeys,
encryptionErrors,
successfulEncryptions.values.every((n) => n > 0),
);
}