From 0480e9156f17c59b1f3d1dd27b5aa46e000c9334 Mon Sep 17 00:00:00 2001 From: "Alexander \"PapaTutuWawa" Date: Thu, 15 Sep 2022 13:46:52 +0200 Subject: [PATCH] fix: Fix occurence of not using synchronized's return --- lib/src/omemo/sessionmanager.dart | 21 ++++++++------------- 1 file changed, 8 insertions(+), 13 deletions(-) diff --git a/lib/src/omemo/sessionmanager.dart b/lib/src/omemo/sessionmanager.dart index 7ab9125..3e924e1 100644 --- a/lib/src/omemo/sessionmanager.dart +++ b/lib/src/omemo/sessionmanager.dart @@ -97,12 +97,7 @@ class OmemoSessionManager { /// Returns our own device. Future getDevice() async { - Device? dev; - await _deviceLock.synchronized(() async { - dev = _device; - }); - - return dev!; + return _deviceLock.synchronized(() => _device); } /// Returns the id attribute of our own device. This is just a short-hand for @@ -177,14 +172,14 @@ class OmemoSessionManager { Future _addSessionFromKeyExchange(String jid, int deviceId, OmemoKeyExchange kex) async { // Pick the correct SPK final device = await getDevice(); - OmemoKeyPair? spk; - - await _lock.synchronized(() async { + final spk = await _lock.synchronized(() async { if (kex.spkId == _device.spkId) { - spk = _device.spk; + return _device.spk; } else if (kex.spkId == _device.oldSpkId) { - spk = _device.oldSpk; + return _device.oldSpk; } + + return null; }); if (spk == null) { throw UnknownSignedPrekeyException(); @@ -196,12 +191,12 @@ class OmemoSessionManager { OmemoPublicKey.fromBytes(kex.ek!, KeyPairType.x25519), kex.pkId!, ), - spk!, + spk, device.opks.values.elementAt(kex.pkId!), device.ik, ); final ratchet = await OmemoDoubleRatchet.acceptNewSession( - spk!, + spk, OmemoPublicKey.fromBytes(kex.ik!, KeyPairType.ed25519), kexResult.sk, kexResult.ad,