Compare commits

..

4 Commits

5 changed files with 21 additions and 9 deletions

View File

@ -15,3 +15,8 @@
- Add convenience functions `getDeviceId` and `getDeviceBundle` - Add convenience functions `getDeviceId` and `getDeviceBundle`
- Creating a new ratchet with an id for which we already have a ratchet will now overwrite the old ratchet - Creating a new ratchet with an id for which we already have a ratchet will now overwrite the old ratchet
- Ratchet now carry an "acknowledged" attribute - Ratchet now carry an "acknowledged" attribute
## 0.2.1
- Add `isRatchetAcknowledged`
- Ratchets that are created due to accepting a kex are now unacknowledged

View File

@ -197,7 +197,7 @@ class OmemoDoubleRatchet {
ik, ik,
ad, ad,
{}, {},
true, false,
); );
} }

View File

@ -446,18 +446,25 @@ class OmemoSessionManager {
/// Returns the list of device identifiers belonging to [jid] that are yet unacked, i.e. /// Returns the list of device identifiers belonging to [jid] that are yet unacked, i.e.
/// we have not yet received an empty OMEMO message from. /// we have not yet received an empty OMEMO message from.
Future<List<int>> getUnacknowledgedRatchets(String jid) async { Future<List<int>?> getUnacknowledgedRatchets(String jid) async {
return _lock.synchronized(() async {
final ret = List<int>.empty(growable: true); final ret = List<int>.empty(growable: true);
final devices = _deviceMap[jid];
if (devices == null) return null;
await _lock.synchronized(() async {
final devices = _deviceMap[jid]!;
for (final device in devices) { for (final device in devices) {
final ratchet = _ratchetMap[RatchetMapKey(jid, device)]!; final ratchet = _ratchetMap[RatchetMapKey(jid, device)]!;
if (!ratchet.acknowledged) ret.add(device); if (!ratchet.acknowledged) ret.add(device);
} }
});
return ret; return ret;
});
}
/// Returns true if the ratchet for [jid] with device identifier [deviceId] is
/// acknowledged. Returns false if not.
Future<bool> isRatchetAcknowledged(String jid, int deviceId) async {
return _lock.synchronized(() => _ratchetMap[RatchetMapKey(jid, deviceId)]!.acknowledged);
} }
/// Mark the ratchet for device [deviceId] from [jid] as acked. /// Mark the ratchet for device [deviceId] from [jid] as acked.

View File

@ -1,6 +1,6 @@
name: omemo_dart name: omemo_dart
description: An XMPP library independent OMEMO library description: An XMPP library independent OMEMO library
version: 0.2.0 version: 0.2.1
homepage: https://github.com/PapaTutuWawa/omemo_dart homepage: https://github.com/PapaTutuWawa/omemo_dart
publish_to: https://git.polynom.me/api/packages/PapaTutuWawa/pub publish_to: https://git.polynom.me/api/packages/PapaTutuWawa/pub

View File

@ -539,7 +539,7 @@ void main() {
// Alice marks the ratchet as acknowledged // Alice marks the ratchet as acknowledged
await aliceSession.ratchetAcknowledged(bobJid, await bobSession.getDeviceId()); await aliceSession.ratchetAcknowledged(bobJid, await bobSession.getDeviceId());
expect( expect(
(await aliceSession.getUnacknowledgedRatchets(bobJid)).isEmpty, (await aliceSession.getUnacknowledgedRatchets(bobJid))!.isEmpty,
true, true,
); );
}); });