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 {
fun map(restDeviceInfo: DeviceKeysWithUnsigned): CryptoDeviceInfo {
fun map(deviceKeysWithUnsigned: DeviceKeysWithUnsigned): CryptoDeviceInfo {
return CryptoDeviceInfo(
deviceId = restDeviceInfo.deviceId ?: "",
userId = restDeviceInfo.userId ?: "",
algorithms = restDeviceInfo.algorithms,
keys = restDeviceInfo.keys,
signatures = restDeviceInfo.signatures,
unsigned = restDeviceInfo.unsigned,
deviceId = deviceKeysWithUnsigned.deviceId,
userId = deviceKeysWithUnsigned.userId,
algorithms = deviceKeysWithUnsigned.algorithms,
keys = deviceKeysWithUnsigned.keys,
signatures = deviceKeysWithUnsigned.signatures,
unsigned = deviceKeysWithUnsigned.unsigned,
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.
*/
@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.
*/
@Json(name = "device_id")
val deviceId: String?,
val deviceId: String,
/**
* 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"
// deviceInfoData contains serialized data
internal open class DeviceInfoEntity(@PrimaryKey var primaryKey: String = "",
var deviceId: String? = null,
var identityKey: String? = null,
// var deviceInfoData: String? = null,
var userId: String? = null,
var isBlocked: Boolean? = null,
var algorithmListJson: String? = null,
var keysMapJson: String? = null,
var signatureMapJson: String? = null,
var unsignedMapJson: String? = null,
var trustLevelEntity: TrustLevelEntity? = null,
/**
* We use that to make distinction between old devices (there before mine)
* and new ones. Used for example to detect new unverified login
*/
var firstTimeSeenLocalTs: Long? = null
internal open class DeviceInfoEntity(
@PrimaryKey var primaryKey: String = "",
var deviceId: String? = null,
var identityKey: String? = null,
var userId: String? = null,
var isBlocked: Boolean? = null,
var algorithmListJson: String? = null,
var keysMapJson: String? = null,
var signatureMapJson: String? = null,
// Will contain the device name from unsigned data if present
var unsignedMapJson: String? = null,
var trustLevelEntity: TrustLevelEntity? = null,
/**
* We use that to make distinction between old devices (there before mine)
* and new ones. Used for example to detect new unverified login
*/
var firstTimeSeenLocalTs: Long? = null
) : RealmObject() {
// // Deserialize data
// fun getDeviceInfo(): MXDeviceInfo? {
// return deserializeFromRealm(deviceInfoData)
// }
//
// // Serialize data
// fun putDeviceInfo(deviceInfo: MXDeviceInfo?) {
// deviceInfoData = serializeForRealm(deviceInfo)
// }
@LinkingObjects("devices")
val users: RealmResults<UserEntity>? = null