Valere's review

This commit is contained in:
Benoit Marty 2019-07-04 14:59:29 +02:00
parent e5958983d8
commit 6cbd6d3a33
4 changed files with 13 additions and 16 deletions

View file

@ -210,11 +210,7 @@ class CreateRoomParams {
* @return the first invited user id
*/
fun getFirstInvitedUserId(): String? {
if (getInviteCount() > 0) {
return invitedUserIds?.firstOrNull()
}
return invite3pids?.firstOrNull()?.address
return invitedUserIds?.firstOrNull() ?: invite3pids?.firstOrNull()?.address
}
/**

View file

@ -176,7 +176,7 @@ internal class MXOlmDecryption(
sessionIds = ArrayList(sessionIdsSet)
}
val messageBody = message["body"] as String?
val messageBody = message["body"] as? String
var messageType: Int? = null
val typeAsVoid = message["type"]

View file

@ -45,7 +45,6 @@ import im.vector.matrix.android.internal.crypto.keysbackup.tasks.*
import im.vector.matrix.android.internal.crypto.keysbackup.util.computeRecoveryKey
import im.vector.matrix.android.internal.crypto.keysbackup.util.extractCurveKeyFromRecoveryKey
import im.vector.matrix.android.internal.crypto.model.ImportRoomKeysResult
import im.vector.matrix.android.internal.crypto.model.MXDeviceInfo
import im.vector.matrix.android.internal.crypto.model.OlmInboundGroupSessionWrapper
import im.vector.matrix.android.internal.crypto.store.IMXCryptoStore
import im.vector.matrix.android.internal.crypto.store.db.model.KeysBackupDataEntity
@ -389,7 +388,7 @@ internal class KeysBackup @Inject constructor(
}
val mySigs = authData.signatures?.get(myUserId)
if (mySigs == null || mySigs.isEmpty()) {
if (mySigs.isNullOrEmpty()) {
Timber.v("getKeysBackupTrust: Ignoring key backup because it lacks any signatures from this user")
return keysBackupVersionTrust
}
@ -403,18 +402,20 @@ internal class KeysBackup @Inject constructor(
}
if (deviceId != null) {
var device = cryptoStore.getUserDevice(deviceId, myUserId)
val device = cryptoStore.getUserDevice(deviceId, myUserId)
var isSignatureValid = false
if (device == null) {
Timber.v("getKeysBackupTrust: Signature from unknown device $deviceId")
} else {
try {
olmDevice.verifySignature(device.fingerprint()!!, authData.signalableJSONDictionary(), mySigs[keyId] as String)
isSignatureValid = true
} catch (e: OlmException) {
Timber.v("getKeysBackupTrust: Bad signature from device " + device.deviceId + " " + e.localizedMessage)
val fingerprint = device.fingerprint()
if (fingerprint != null) {
try {
olmDevice.verifySignature(fingerprint, authData.signalableJSONDictionary(), mySigs[keyId] as String)
isSignatureValid = true
} catch (e: OlmException) {
Timber.v("getKeysBackupTrust: Bad signature from device " + device.deviceId + " " + e.localizedMessage)
}
}
if (isSignatureValid && device.isVerified) {

View file

@ -124,7 +124,7 @@ data class MXDeviceInfo(
* @return the display name
*/
fun displayName(): String? {
return unsigned?.get("device_display_name") as String?
return unsigned?.get("device_display_name") as? String
}
/**