fix: use a when to make logic more readable

pull/450/head
jubb 4 years ago
parent 7e86343efe
commit c740963fe2

@ -616,10 +616,12 @@ object ClosedGroupsProtocolV2 {
val userKeyPair = apiDB.getUserX25519KeyPair() val userKeyPair = apiDB.getUserX25519KeyPair()
// Unwrap the message // Unwrap the message
val groupDB = DatabaseFactory.getGroupDatabase(context) val groupDB = DatabaseFactory.getGroupDatabase(context)
val groupID = if (groupPublicKey.isEmpty() && !closedGroupUpdate.publicKey.isEmpty) { val groupID = when {
doubleEncodeGroupID(closedGroupUpdate.publicKey.toStringUtf8()) groupPublicKey.isNotEmpty() -> groupPublicKey
} else { !closedGroupUpdate.publicKey.isEmpty -> closedGroupUpdate.publicKey.toStringUtf8()
doubleEncodeGroupID(groupPublicKey) else -> ""
}.let {
doubleEncodeGroupID(it)
} }
val group = groupDB.getGroup(groupID).orNull() val group = groupDB.getGroup(groupID).orNull()
if (group == null) { if (group == null) {

Loading…
Cancel
Save