fix: Fix crash when calling getUnacknowledgedRatchets for a new Jid
This commit is contained in:
parent
f68e45af26
commit
80e1b20f27
@ -446,18 +446,19 @@ 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 {
|
||||||
final ret = List<int>.empty(growable: true);
|
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) {
|
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;
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Mark the ratchet for device [deviceId] from [jid] as acked.
|
/// Mark the ratchet for device [deviceId] from [jid] as acked.
|
||||||
|
@ -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,
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
Loading…
Reference in New Issue
Block a user