3 Commits
Author SHA1 Message Date
PapaTutuWawa 7600804aa1 test: Uncomment those tests 2022-08-11 12:02:33 +02:00
PapaTutuWawa a4589b6e09 feat: Allow access to the device map 2022-08-11 12:02:21 +02:00
PapaTutuWawa d0986a4608 fix: Fix ratchet only working for one message 2022-08-11 11:57:33 +02:00
3 changed files with 18 additions and 5 deletions

No files matched your search

+5 -1
View File
@@ -293,7 +293,11 @@ class OmemoDoubleRatchet {
return plaintext;
}
if (header.dhPub != await dhr?.getBytes()) {
final dhPubMatches = listsEqual(
header.dhPub ?? <int>[],
await dhr?.getBytes() ?? <int>[],
);
if (!dhPubMatches) {
await _skipMessageKeys(header.pn!);
await _dhRatchet(header);
}
+12 -3
View File
@@ -387,11 +387,20 @@ class OmemoSessionManager {
});
}
@visibleForTesting
OmemoDoubleRatchet getRatchet(String jid, int deviceId) => _ratchetMap[RatchetMapKey(jid, deviceId)]!;
/// Returns the device map, i.e. the mapping of bare Jid to its device identifiers
/// we have built sessions with.
Future<Map<String, List<int>>> getDeviceMap() async {
Map<String, List<int>>? map;
await _lock.synchronized(() async {
map = _deviceMap;
});
return map!;
}
@visibleForTesting
Map<String, List<int>> getDeviceMap() => _deviceMap;
OmemoDoubleRatchet getRatchet(String jid, int deviceId) => _ratchetMap[RatchetMapKey(jid, deviceId)]!;
@visibleForTesting
Map<RatchetMapKey, OmemoDoubleRatchet> getRatchetMap() => _ratchetMap;
+1 -1
View File
@@ -93,7 +93,7 @@ void main() {
final oldDevice = await oldSession.getDevice();
final newDevice = await newSession.getDevice();
expect(await oldDevice.equals(newDevice), true);
expect(oldSession.getDeviceMap(), newSession.getDeviceMap());
expect(await oldSession.getDeviceMap(), await newSession.getDeviceMap());
expect(oldSession.getRatchetMap().length, newSession.getRatchetMap().length);
for (final session in oldSession.getRatchetMap().entries) {