Auto-review

This commit is contained in:
Benoit Marty 2020-06-20 00:09:36 +02:00
parent 4125baf066
commit 2e93b7c4c9
3 changed files with 26 additions and 36 deletions

View file

@ -21,14 +21,14 @@ import im.vector.matrix.android.internal.crypto.model.rest.RestKeyInfo
internal object CryptoInfoMapper { internal object CryptoInfoMapper {
fun map(restDeviceInfo: DeviceKeysWithUnsigned): CryptoDeviceInfo { fun map(deviceKeysWithUnsigned: DeviceKeysWithUnsigned): CryptoDeviceInfo {
return CryptoDeviceInfo( return CryptoDeviceInfo(
deviceId = restDeviceInfo.deviceId ?: "", deviceId = deviceKeysWithUnsigned.deviceId,
userId = restDeviceInfo.userId ?: "", userId = deviceKeysWithUnsigned.userId,
algorithms = restDeviceInfo.algorithms, algorithms = deviceKeysWithUnsigned.algorithms,
keys = restDeviceInfo.keys, keys = deviceKeysWithUnsigned.keys,
signatures = restDeviceInfo.signatures, signatures = deviceKeysWithUnsigned.signatures,
unsigned = restDeviceInfo.unsigned, unsigned = deviceKeysWithUnsigned.unsigned,
trustLevel = null trustLevel = null
) )
} }

View file

@ -25,13 +25,13 @@ data class DeviceKeysWithUnsigned(
* Required. The ID of the user the device belongs to. Must match the user ID used when logging in. * Required. The ID of the user the device belongs to. Must match the user ID used when logging in.
*/ */
@Json(name = "user_id") @Json(name = "user_id")
val userId: String?, val userId: String,
/** /**
* Required. The ID of the device these keys belong to. Must match the device ID used when logging in. * Required. The ID of the device these keys belong to. Must match the device ID used when logging in.
*/ */
@Json(name = "device_id") @Json(name = "device_id")
val deviceId: String?, val deviceId: String,
/** /**
* Required. The encryption algorithms supported by this device. * Required. The encryption algorithms supported by this device.

View file

@ -23,35 +23,25 @@ import io.realm.annotations.PrimaryKey
internal fun DeviceInfoEntity.Companion.createPrimaryKey(userId: String, deviceId: String) = "$userId|$deviceId" internal fun DeviceInfoEntity.Companion.createPrimaryKey(userId: String, deviceId: String) = "$userId|$deviceId"
// deviceInfoData contains serialized data internal open class DeviceInfoEntity(
internal open class DeviceInfoEntity(@PrimaryKey var primaryKey: String = "", @PrimaryKey var primaryKey: String = "",
var deviceId: String? = null, var deviceId: String? = null,
var identityKey: String? = null, var identityKey: String? = null,
// var deviceInfoData: String? = null, var userId: String? = null,
var userId: String? = null, var isBlocked: Boolean? = null,
var isBlocked: Boolean? = null, var algorithmListJson: String? = null,
var algorithmListJson: String? = null, var keysMapJson: String? = null,
var keysMapJson: String? = null, var signatureMapJson: String? = null,
var signatureMapJson: String? = null, // Will contain the device name from unsigned data if present
var unsignedMapJson: String? = null, var unsignedMapJson: String? = null,
var trustLevelEntity: TrustLevelEntity? = null, var trustLevelEntity: TrustLevelEntity? = null,
/** /**
* We use that to make distinction between old devices (there before mine) * We use that to make distinction between old devices (there before mine)
* and new ones. Used for example to detect new unverified login * and new ones. Used for example to detect new unverified login
*/ */
var firstTimeSeenLocalTs: Long? = null var firstTimeSeenLocalTs: Long? = null
) : RealmObject() { ) : RealmObject() {
// // Deserialize data
// fun getDeviceInfo(): MXDeviceInfo? {
// return deserializeFromRealm(deviceInfoData)
// }
//
// // Serialize data
// fun putDeviceInfo(deviceInfo: MXDeviceInfo?) {
// deviceInfoData = serializeForRealm(deviceInfo)
// }
@LinkingObjects("devices") @LinkingObjects("devices")
val users: RealmResults<UserEntity>? = null val users: RealmResults<UserEntity>? = null