Compare commits
4 Commits
f68e45af26
...
b6aa28e1ee
Author | SHA1 | Date | |
---|---|---|---|
b6aa28e1ee | |||
2e10842c54 | |||
0e2af1f2a3 | |||
80e1b20f27 |
@ -15,3 +15,8 @@
|
||||
- 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
|
||||
- Ratchet now carry an "acknowledged" attribute
|
||||
|
||||
## 0.2.1
|
||||
|
||||
- Add `isRatchetAcknowledged`
|
||||
- Ratchets that are created due to accepting a kex are now unacknowledged
|
||||
|
@ -197,7 +197,7 @@ class OmemoDoubleRatchet {
|
||||
ik,
|
||||
ad,
|
||||
{},
|
||||
true,
|
||||
false,
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -446,18 +446,25 @@ class OmemoSessionManager {
|
||||
|
||||
/// 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.
|
||||
Future<List<int>> getUnacknowledgedRatchets(String jid) async {
|
||||
final ret = List<int>.empty(growable: true);
|
||||
Future<List<int>?> getUnacknowledgedRatchets(String jid) async {
|
||||
return _lock.synchronized(() async {
|
||||
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) {
|
||||
final ratchet = _ratchetMap[RatchetMapKey(jid, 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.
|
||||
|
@ -1,6 +1,6 @@
|
||||
name: omemo_dart
|
||||
description: An XMPP library independent OMEMO library
|
||||
version: 0.2.0
|
||||
version: 0.2.1
|
||||
homepage: https://github.com/PapaTutuWawa/omemo_dart
|
||||
publish_to: https://git.polynom.me/api/packages/PapaTutuWawa/pub
|
||||
|
||||
|
@ -539,7 +539,7 @@ void main() {
|
||||
// Alice marks the ratchet as acknowledged
|
||||
await aliceSession.ratchetAcknowledged(bobJid, await bobSession.getDeviceId());
|
||||
expect(
|
||||
(await aliceSession.getUnacknowledgedRatchets(bobJid)).isEmpty,
|
||||
(await aliceSession.getUnacknowledgedRatchets(bobJid))!.isEmpty,
|
||||
true,
|
||||
);
|
||||
});
|
||||
|
Loading…
Reference in New Issue
Block a user