Realm crypto: migrate entity classes
This commit is contained in:
parent
4040593608
commit
462d1bce68
@ -16,15 +16,13 @@
|
||||
|
||||
package org.matrix.android.sdk.internal.crypto.store.db.model
|
||||
|
||||
import io.realm.RealmModel
|
||||
import io.realm.annotations.Index
|
||||
import io.realm.annotations.RealmClass
|
||||
import io.realm.kotlin.types.RealmObject
|
||||
import io.realm.kotlin.types.annotations.Index
|
||||
|
||||
internal class AuditTrailEntity : RealmObject {
|
||||
var ageLocalTs: Long? = null
|
||||
@Index var type: String? = null
|
||||
var contentJson: String? = null
|
||||
|
||||
@RealmClass
|
||||
internal open class AuditTrailEntity(
|
||||
var ageLocalTs: Long? = null,
|
||||
@Index var type: String? = null,
|
||||
var contentJson: String? = null
|
||||
) : RealmModel {
|
||||
companion object
|
||||
}
|
||||
|
@ -16,20 +16,16 @@
|
||||
|
||||
package org.matrix.android.sdk.internal.crypto.store.db.model
|
||||
|
||||
import io.realm.RealmList
|
||||
import io.realm.RealmModel
|
||||
import io.realm.annotations.PrimaryKey
|
||||
import io.realm.annotations.RealmClass
|
||||
import io.realm.kotlin.deleteFromRealm
|
||||
import io.realm.kotlin.ext.realmListOf
|
||||
import io.realm.kotlin.types.RealmList
|
||||
import io.realm.kotlin.types.RealmObject
|
||||
import io.realm.kotlin.types.annotations.PrimaryKey
|
||||
import org.matrix.android.sdk.api.session.crypto.crosssigning.KeyUsage
|
||||
import org.matrix.android.sdk.internal.extensions.clearWith
|
||||
|
||||
@RealmClass
|
||||
internal open class CrossSigningInfoEntity(
|
||||
@PrimaryKey
|
||||
var userId: String? = null,
|
||||
var crossSigningKeys: RealmList<KeyInfoEntity> = RealmList()
|
||||
) : RealmModel {
|
||||
internal class CrossSigningInfoEntity : RealmObject {
|
||||
@PrimaryKey
|
||||
var userId: String? = null
|
||||
var crossSigningKeys: RealmList<KeyInfoEntity> = realmListOf()
|
||||
|
||||
companion object
|
||||
|
||||
@ -61,7 +57,10 @@ internal open class CrossSigningInfoEntity(
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
internal fun CrossSigningInfoEntity.deleteOnCascade() {
|
||||
crossSigningKeys.clearWith { it.deleteOnCascade() }
|
||||
deleteFromRealm()
|
||||
}
|
||||
|
||||
*/
|
||||
|
@ -16,46 +16,48 @@
|
||||
|
||||
package org.matrix.android.sdk.internal.crypto.store.db.model
|
||||
|
||||
import io.realm.RealmModel
|
||||
import io.realm.annotations.PrimaryKey
|
||||
import io.realm.annotations.RealmClass
|
||||
import io.realm.kotlin.types.RealmObject
|
||||
import io.realm.kotlin.types.annotations.PrimaryKey
|
||||
import org.matrix.android.sdk.internal.crypto.store.db.deserializeFromRealm
|
||||
import org.matrix.android.sdk.internal.crypto.store.db.serializeForRealm
|
||||
import org.matrix.olm.OlmAccount
|
||||
|
||||
@RealmClass
|
||||
internal open class CryptoMetadataEntity(
|
||||
// The current user id.
|
||||
@PrimaryKey var userId: String? = null,
|
||||
// The current device id.
|
||||
var deviceId: String? = null,
|
||||
// Serialized OlmAccount
|
||||
var olmAccountData: String? = null,
|
||||
// The sync token corresponding to the device list. // TODO?
|
||||
var deviceSyncToken: String? = null,
|
||||
// Settings for blacklisting unverified devices.
|
||||
var globalBlacklistUnverifiedDevices: Boolean = false,
|
||||
// setting to enable or disable key gossiping
|
||||
var globalEnableKeyGossiping: Boolean = true,
|
||||
internal class CryptoMetadataEntity : RealmObject {
|
||||
// The current user id.
|
||||
@PrimaryKey var userId: String? = null
|
||||
|
||||
// MSC3061: Sharing room keys for past messages
|
||||
// If set to true key history will be shared to invited users with respect to room setting
|
||||
var enableKeyForwardingOnInvite: Boolean = false,
|
||||
// The current device id.
|
||||
var deviceId: String? = null
|
||||
|
||||
// The keys backup version currently used. Null means no backup.
|
||||
var backupVersion: String? = null,
|
||||
// Serialized OlmAccount
|
||||
var olmAccountData: String? = null
|
||||
|
||||
// The device keys has been sent to the homeserver
|
||||
var deviceKeysSentToServer: Boolean = false,
|
||||
// The sync token corresponding to the device list. // TODO?
|
||||
var deviceSyncToken: String? = null
|
||||
|
||||
var xSignMasterPrivateKey: String? = null,
|
||||
var xSignUserPrivateKey: String? = null,
|
||||
var xSignSelfSignedPrivateKey: String? = null,
|
||||
var keyBackupRecoveryKey: String? = null,
|
||||
var keyBackupRecoveryKeyVersion: String? = null
|
||||
// Settings for blacklisting unverified devices.
|
||||
var globalBlacklistUnverifiedDevices: Boolean = false
|
||||
|
||||
// setting to enable or disable key gossiping
|
||||
var globalEnableKeyGossiping: Boolean = true
|
||||
|
||||
// MSC3061: Sharing room keys for past messages
|
||||
// If set to true key history will be shared to invited users with respect to room setting
|
||||
var enableKeyForwardingOnInvite: Boolean = false
|
||||
|
||||
// The keys backup version currently used. Null means no backup.
|
||||
var backupVersion: String? = null
|
||||
|
||||
// The device keys has been sent to the homeserver
|
||||
var deviceKeysSentToServer: Boolean = false
|
||||
|
||||
var xSignMasterPrivateKey: String? = null
|
||||
var xSignUserPrivateKey: String? = null
|
||||
var xSignSelfSignedPrivateKey: String? = null
|
||||
var keyBackupRecoveryKey: String? = null
|
||||
var keyBackupRecoveryKeyVersion: String? = null
|
||||
|
||||
// var crossSigningInfoEntity: CrossSigningInfoEntity? = null
|
||||
) : RealmModel {
|
||||
|
||||
// Deserialize data
|
||||
fun getOlmAccount(): OlmAccount? {
|
||||
|
@ -16,27 +16,26 @@
|
||||
|
||||
package org.matrix.android.sdk.internal.crypto.store.db.model
|
||||
|
||||
import io.realm.RealmModel
|
||||
import io.realm.annotations.PrimaryKey
|
||||
import io.realm.annotations.RealmClass
|
||||
import io.realm.kotlin.types.RealmObject
|
||||
import io.realm.kotlin.types.annotations.PrimaryKey
|
||||
|
||||
@RealmClass
|
||||
internal open class CryptoRoomEntity(
|
||||
@PrimaryKey var roomId: String? = null,
|
||||
var algorithm: String? = null,
|
||||
var shouldEncryptForInvitedMembers: Boolean? = null,
|
||||
var blacklistUnverifiedDevices: Boolean = false,
|
||||
// Determines whether or not room history should be shared on new member invites
|
||||
var shouldShareHistory: Boolean = false,
|
||||
// Store the current outbound session for this room,
|
||||
// to avoid re-create and re-share at each startup (if rotation not needed..)
|
||||
// This is specific to megolm but not sure how to model it better
|
||||
var outboundSessionInfo: OutboundGroupSessionInfoEntity? = null,
|
||||
// a security to ensure that a room will never revert to not encrypted
|
||||
// even if a new state event with empty encryption, or state is reset somehow
|
||||
var wasEncryptedOnce: Boolean? = false
|
||||
) :
|
||||
RealmModel {
|
||||
internal class CryptoRoomEntity : RealmObject {
|
||||
@PrimaryKey var roomId: String? = null
|
||||
var algorithm: String? = null
|
||||
var shouldEncryptForInvitedMembers: Boolean? = null
|
||||
var blacklistUnverifiedDevices: Boolean = false
|
||||
|
||||
// Determines whether or not room history should be shared on new member invites
|
||||
var shouldShareHistory: Boolean = false
|
||||
|
||||
// Store the current outbound session for this room,
|
||||
// to avoid re-create and re-share at each startup (if rotation not needed..)
|
||||
// This is specific to megolm but not sure how to model it better
|
||||
var outboundSessionInfo: OutboundGroupSessionInfoEntity? = null
|
||||
|
||||
// a security to ensure that a room will never revert to not encrypted
|
||||
// even if a new state event with empty encryption, or state is reset somehow
|
||||
var wasEncryptedOnce: Boolean? = false
|
||||
|
||||
companion object
|
||||
}
|
||||
|
@ -16,42 +16,38 @@
|
||||
|
||||
package org.matrix.android.sdk.internal.crypto.store.db.model
|
||||
|
||||
import io.realm.RealmModel
|
||||
import io.realm.RealmResults
|
||||
import io.realm.annotations.LinkingObjects
|
||||
import io.realm.annotations.PrimaryKey
|
||||
import io.realm.annotations.RealmClass
|
||||
import io.realm.kotlin.deleteFromRealm
|
||||
import io.realm.kotlin.types.RealmObject
|
||||
import io.realm.kotlin.types.annotations.PrimaryKey
|
||||
|
||||
internal fun DeviceInfoEntity.Companion.createPrimaryKey(userId: String, deviceId: String) = "$userId|$deviceId"
|
||||
|
||||
@RealmClass
|
||||
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
|
||||
) : RealmModel {
|
||||
internal class DeviceInfoEntity : RealmObject {
|
||||
@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
|
||||
|
||||
@LinkingObjects("devices")
|
||||
val users: RealmResults<UserEntity>? = 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
|
||||
|
||||
companion object
|
||||
}
|
||||
|
||||
/*
|
||||
internal fun DeviceInfoEntity.deleteOnCascade() {
|
||||
trustLevelEntity?.deleteFromRealm()
|
||||
deleteFromRealm()
|
||||
}
|
||||
|
||||
*/
|
||||
|
@ -16,25 +16,28 @@
|
||||
|
||||
package org.matrix.android.sdk.internal.crypto.store.db.model
|
||||
|
||||
import io.realm.RealmList
|
||||
import io.realm.RealmModel
|
||||
import io.realm.annotations.RealmClass
|
||||
import io.realm.kotlin.deleteFromRealm
|
||||
import io.realm.kotlin.ext.realmListOf
|
||||
import io.realm.kotlin.types.RealmList
|
||||
import io.realm.kotlin.types.RealmObject
|
||||
|
||||
@RealmClass
|
||||
internal open class KeyInfoEntity(
|
||||
var publicKeyBase64: String? = null,
|
||||
// var isTrusted: Boolean = false,
|
||||
var usages: RealmList<String> = RealmList(),
|
||||
/**
|
||||
* The signature of this MXDeviceInfo.
|
||||
* A map from "<userId>" to a map from "<key type>:<Publickey>" to "<signature>"
|
||||
*/
|
||||
var signatures: String? = null,
|
||||
var trustLevelEntity: TrustLevelEntity? = null
|
||||
) : RealmModel
|
||||
internal class KeyInfoEntity : RealmObject {
|
||||
var publicKeyBase64: String? = null
|
||||
|
||||
// var isTrusted: Boolean = false,
|
||||
var usages: RealmList<String> = realmListOf()
|
||||
|
||||
/**
|
||||
* The signature of this MXDeviceInfo.
|
||||
* A map from "<userId>" to a map from "<key type>:<Publickey>" to "<signature>"
|
||||
*/
|
||||
var signatures: String? = null
|
||||
var trustLevelEntity: TrustLevelEntity? = null
|
||||
}
|
||||
|
||||
/*
|
||||
internal fun KeyInfoEntity.deleteOnCascade() {
|
||||
trustLevelEntity?.deleteFromRealm()
|
||||
deleteFromRealm()
|
||||
}
|
||||
|
||||
*/
|
||||
|
@ -16,17 +16,15 @@
|
||||
|
||||
package org.matrix.android.sdk.internal.crypto.store.db.model
|
||||
|
||||
import io.realm.RealmModel
|
||||
import io.realm.annotations.RealmClass
|
||||
import io.realm.kotlin.types.RealmObject
|
||||
import org.matrix.android.sdk.api.session.events.model.Event
|
||||
import org.matrix.android.sdk.internal.di.MoshiProvider
|
||||
|
||||
@RealmClass
|
||||
internal open class KeyRequestReplyEntity(
|
||||
var senderId: String? = null,
|
||||
var fromDevice: String? = null,
|
||||
var eventJson: String? = null
|
||||
) : RealmModel {
|
||||
internal class KeyRequestReplyEntity : RealmObject {
|
||||
var senderId: String? = null
|
||||
var fromDevice: String? = null
|
||||
var eventJson: String? = null
|
||||
|
||||
companion object
|
||||
|
||||
fun getEvent(): Event? {
|
||||
|
@ -16,17 +16,17 @@
|
||||
|
||||
package org.matrix.android.sdk.internal.crypto.store.db.model
|
||||
|
||||
import io.realm.RealmModel
|
||||
import io.realm.annotations.PrimaryKey
|
||||
import io.realm.annotations.RealmClass
|
||||
import io.realm.kotlin.types.RealmObject
|
||||
import io.realm.kotlin.types.annotations.PrimaryKey
|
||||
|
||||
@RealmClass
|
||||
internal open class KeysBackupDataEntity(
|
||||
// Primary key to update this object. There is only one object, so it's a constant, please do not set it
|
||||
@PrimaryKey
|
||||
var primaryKey: Int = 0,
|
||||
// The last known hash of the backed up keys on the server
|
||||
var backupLastServerHash: String? = null,
|
||||
// The last known number of backed up keys on the server
|
||||
var backupLastServerNumberOfKeys: Int? = null
|
||||
) : RealmModel
|
||||
internal class KeysBackupDataEntity : RealmObject {
|
||||
// Primary key to update this object. There is only one object, so it's a constant, please do not set it
|
||||
@PrimaryKey
|
||||
var primaryKey: Int = 0
|
||||
|
||||
// The last known hash of the backed up keys on the server
|
||||
var backupLastServerHash: String? = null
|
||||
|
||||
// The last known number of backed up keys on the server
|
||||
var backupLastServerNumberOfKeys: Int? = null
|
||||
}
|
||||
|
@ -16,21 +16,21 @@
|
||||
|
||||
package org.matrix.android.sdk.internal.crypto.store.db.model
|
||||
|
||||
import io.realm.RealmModel
|
||||
import io.realm.annotations.PrimaryKey
|
||||
import io.realm.annotations.RealmClass
|
||||
import io.realm.kotlin.types.RealmObject
|
||||
import io.realm.kotlin.types.annotations.PrimaryKey
|
||||
|
||||
@RealmClass
|
||||
internal open class MyDeviceLastSeenInfoEntity(
|
||||
/** The device id. */
|
||||
@PrimaryKey var deviceId: String? = null,
|
||||
/** The device display name. */
|
||||
var displayName: String? = null,
|
||||
/** The last time this device has been seen. */
|
||||
var lastSeenTs: Long? = null,
|
||||
/** The last ip address. */
|
||||
var lastSeenIp: String? = null
|
||||
) : RealmModel {
|
||||
internal class MyDeviceLastSeenInfoEntity : RealmObject {
|
||||
/** The device id. */
|
||||
@PrimaryKey var deviceId: String? = null
|
||||
|
||||
/** The device display name. */
|
||||
var displayName: String? = null
|
||||
|
||||
/** The last time this device has been seen. */
|
||||
var lastSeenTs: Long? = null
|
||||
|
||||
/** The last ip address. */
|
||||
var lastSeenIp: String? = null
|
||||
|
||||
companion object
|
||||
}
|
||||
|
@ -16,9 +16,8 @@
|
||||
|
||||
package org.matrix.android.sdk.internal.crypto.store.db.model
|
||||
|
||||
import io.realm.RealmModel
|
||||
import io.realm.annotations.PrimaryKey
|
||||
import io.realm.annotations.RealmClass
|
||||
import io.realm.kotlin.types.RealmObject
|
||||
import io.realm.kotlin.types.annotations.PrimaryKey
|
||||
import org.matrix.android.sdk.internal.crypto.model.InboundGroupSessionData
|
||||
import org.matrix.android.sdk.internal.crypto.model.MXInboundMegolmSessionWrapper
|
||||
import org.matrix.android.sdk.internal.crypto.store.db.deserializeFromRealm
|
||||
@ -29,34 +28,32 @@ import timber.log.Timber
|
||||
|
||||
internal fun OlmInboundGroupSessionEntity.Companion.createPrimaryKey(sessionId: String?, senderKey: String?) = "$sessionId|$senderKey"
|
||||
|
||||
@RealmClass
|
||||
internal open class OlmInboundGroupSessionEntity(
|
||||
// Combined value to build a primary key
|
||||
@PrimaryKey var primaryKey: String? = null,
|
||||
internal class OlmInboundGroupSessionEntity : RealmObject {
|
||||
// Combined value to build a primary key
|
||||
@PrimaryKey var primaryKey: String? = null
|
||||
|
||||
// denormalization for faster querying (these fields are in the inboundGroupSessionDataJson)
|
||||
var sessionId: String? = null,
|
||||
var senderKey: String? = null,
|
||||
var roomId: String? = null,
|
||||
// denormalization for faster querying (these fields are in the inboundGroupSessionDataJson)
|
||||
var sessionId: String? = null
|
||||
var senderKey: String? = null
|
||||
var roomId: String? = null
|
||||
|
||||
// Deprecated, used for migration / olmInboundGroupSessionData contains Json
|
||||
// keep it in case of problem to have a chance to recover
|
||||
var olmInboundGroupSessionData: String? = null,
|
||||
// Deprecated, used for migration / olmInboundGroupSessionData contains Json
|
||||
// keep it in case of problem to have a chance to recover
|
||||
var olmInboundGroupSessionData: String? = null
|
||||
|
||||
// Stores the session data in an extensible format
|
||||
// to allow to store data not yet supported for later use
|
||||
var inboundGroupSessionDataJson: String? = null,
|
||||
// Stores the session data in an extensible format
|
||||
// to allow to store data not yet supported for later use
|
||||
var inboundGroupSessionDataJson: String? = null
|
||||
|
||||
// The pickled session
|
||||
var serializedOlmInboundGroupSession: String? = null,
|
||||
// The pickled session
|
||||
var serializedOlmInboundGroupSession: String? = null
|
||||
|
||||
// Flag that indicates whether or not the current inboundSession will be shared to
|
||||
// invited users to decrypt past messages
|
||||
var sharedHistory: Boolean = false,
|
||||
// Indicate if the key has been backed up to the homeserver
|
||||
var backedUp: Boolean = false
|
||||
) :
|
||||
RealmModel {
|
||||
// Flag that indicates whether or not the current inboundSession will be shared to
|
||||
// invited users to decrypt past messages
|
||||
var sharedHistory: Boolean = false
|
||||
|
||||
// Indicate if the key has been backed up to the homeserver
|
||||
var backedUp: Boolean = false
|
||||
|
||||
fun store(wrapper: MXInboundMegolmSessionWrapper) {
|
||||
this.serializedOlmInboundGroupSession = serializeForRealm(wrapper.session)
|
||||
|
@ -16,9 +16,8 @@
|
||||
|
||||
package org.matrix.android.sdk.internal.crypto.store.db.model
|
||||
|
||||
import io.realm.RealmModel
|
||||
import io.realm.annotations.PrimaryKey
|
||||
import io.realm.annotations.RealmClass
|
||||
import io.realm.kotlin.types.RealmObject
|
||||
import io.realm.kotlin.types.annotations.PrimaryKey
|
||||
import org.matrix.android.sdk.internal.crypto.store.db.deserializeFromRealm
|
||||
import org.matrix.android.sdk.internal.crypto.store.db.serializeForRealm
|
||||
import org.matrix.olm.OlmSession
|
||||
@ -26,15 +25,12 @@ import org.matrix.olm.OlmSession
|
||||
internal fun OlmSessionEntity.Companion.createPrimaryKey(sessionId: String, deviceKey: String) = "$sessionId|$deviceKey"
|
||||
|
||||
// olmSessionData is a serialized OlmSession
|
||||
@RealmClass
|
||||
internal open class OlmSessionEntity(
|
||||
@PrimaryKey var primaryKey: String = "",
|
||||
var sessionId: String? = null,
|
||||
var deviceKey: String? = null,
|
||||
var olmSessionData: String? = null,
|
||||
var lastReceivedMessageTs: Long = 0
|
||||
) :
|
||||
RealmModel {
|
||||
internal class OlmSessionEntity : RealmObject {
|
||||
@PrimaryKey var primaryKey: String = ""
|
||||
var sessionId: String? = null
|
||||
var deviceKey: String? = null
|
||||
var olmSessionData: String? = null
|
||||
var lastReceivedMessageTs: Long = 0
|
||||
|
||||
fun getOlmSession(): OlmSession? {
|
||||
return deserializeFromRealm(olmSessionData)
|
||||
|
@ -16,19 +16,16 @@
|
||||
|
||||
package org.matrix.android.sdk.internal.crypto.store.db.model
|
||||
|
||||
import io.realm.RealmModel
|
||||
import io.realm.annotations.RealmClass
|
||||
import io.realm.kotlin.types.RealmObject
|
||||
import org.matrix.android.sdk.internal.crypto.store.db.deserializeFromRealm
|
||||
import org.matrix.android.sdk.internal.crypto.store.db.serializeForRealm
|
||||
import org.matrix.olm.OlmOutboundGroupSession
|
||||
import timber.log.Timber
|
||||
|
||||
@RealmClass
|
||||
internal open class OutboundGroupSessionInfoEntity(
|
||||
var serializedOutboundSessionData: String? = null,
|
||||
var creationTime: Long? = null,
|
||||
var shouldShareHistory: Boolean = false
|
||||
) : RealmModel {
|
||||
internal class OutboundGroupSessionInfoEntity : RealmObject {
|
||||
var serializedOutboundSessionData: String? = null
|
||||
var creationTime: Long? = null
|
||||
var shouldShareHistory: Boolean = false
|
||||
|
||||
fun getOutboundGroupSession(): OlmOutboundGroupSession? {
|
||||
return try {
|
||||
|
@ -18,11 +18,11 @@ package org.matrix.android.sdk.internal.crypto.store.db.model
|
||||
|
||||
import com.squareup.moshi.JsonAdapter
|
||||
import com.squareup.moshi.Types
|
||||
import io.realm.RealmList
|
||||
import io.realm.RealmModel
|
||||
import io.realm.annotations.Index
|
||||
import io.realm.annotations.RealmClass
|
||||
import io.realm.kotlin.deleteFromRealm
|
||||
import io.realm.kotlin.ext.realmListOf
|
||||
import io.realm.kotlin.types.RealmList
|
||||
import io.realm.kotlin.types.RealmObject
|
||||
import io.realm.kotlin.types.annotations.Index
|
||||
import org.matrix.android.sdk.api.extensions.tryOrNull
|
||||
import org.matrix.android.sdk.api.session.crypto.OutgoingKeyRequest
|
||||
import org.matrix.android.sdk.api.session.crypto.OutgoingRoomKeyRequestState
|
||||
@ -35,19 +35,17 @@ import org.matrix.android.sdk.api.session.events.model.content.RoomKeyWithHeldCo
|
||||
import org.matrix.android.sdk.api.session.events.model.toModel
|
||||
import org.matrix.android.sdk.internal.di.MoshiProvider
|
||||
|
||||
@RealmClass
|
||||
internal open class OutgoingKeyRequestEntity(
|
||||
@Index var requestId: String? = null,
|
||||
var requestedIndex: Int? = null,
|
||||
var recipientsData: String? = null,
|
||||
var requestedInfoStr: String? = null,
|
||||
var creationTimeStamp: Long? = null,
|
||||
// de-normalization for better query (if not have to query all and parse json)
|
||||
@Index var roomId: String? = null,
|
||||
@Index var megolmSessionId: String? = null,
|
||||
internal class OutgoingKeyRequestEntity : RealmObject {
|
||||
@Index var requestId: String? = null
|
||||
var requestedIndex: Int? = null
|
||||
var recipientsData: String? = null
|
||||
var requestedInfoStr: String? = null
|
||||
var creationTimeStamp: Long? = null
|
||||
|
||||
var replies: RealmList<KeyRequestReplyEntity> = RealmList()
|
||||
) : RealmModel {
|
||||
// de-normalization for better query (if not have to query all and parse json)
|
||||
@Index var roomId: String? = null
|
||||
@Index var megolmSessionId: String? = null
|
||||
var replies: RealmList<KeyRequestReplyEntity> = realmListOf()
|
||||
|
||||
@Index private var requestStateStr: String = OutgoingRoomKeyRequestState.UNSENT.name
|
||||
|
||||
@ -87,11 +85,11 @@ internal open class OutgoingKeyRequestEntity(
|
||||
}
|
||||
|
||||
fun addReply(userId: String, fromDevice: String?, event: Event) {
|
||||
val newReply = KeyRequestReplyEntity(
|
||||
senderId = userId,
|
||||
fromDevice = fromDevice,
|
||||
eventJson = MoshiProvider.providesMoshi().adapter(Event::class.java).toJson(event)
|
||||
)
|
||||
val newReply = KeyRequestReplyEntity().apply {
|
||||
this.senderId = userId
|
||||
this.fromDevice = fromDevice
|
||||
this.eventJson = MoshiProvider.providesMoshi().adapter(Event::class.java).toJson(event)
|
||||
}
|
||||
replies.add(newReply)
|
||||
}
|
||||
|
||||
@ -133,7 +131,10 @@ internal open class OutgoingKeyRequestEntity(
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
internal fun OutgoingKeyRequestEntity.deleteOnCascade() {
|
||||
replies.deleteAllFromRealm()
|
||||
deleteFromRealm()
|
||||
}
|
||||
|
||||
*/
|
||||
|
@ -16,25 +16,22 @@
|
||||
|
||||
package org.matrix.android.sdk.internal.crypto.store.db.model
|
||||
|
||||
import io.realm.RealmModel
|
||||
import io.realm.annotations.Index
|
||||
import io.realm.annotations.RealmClass
|
||||
import io.realm.kotlin.types.RealmObject
|
||||
import io.realm.kotlin.types.annotations.Index
|
||||
|
||||
/**
|
||||
* Keep a record of to whom (user/device) a given session should have been shared.
|
||||
* It will be used to reply to keyshare requests from other users, in order to see if
|
||||
* this session was originaly shared with a given user
|
||||
*/
|
||||
@RealmClass
|
||||
internal open class SharedSessionEntity(
|
||||
var roomId: String? = null,
|
||||
var algorithm: String? = null,
|
||||
@Index var sessionId: String? = null,
|
||||
@Index var userId: String? = null,
|
||||
@Index var deviceId: String? = null,
|
||||
@Index var deviceIdentityKey: String? = null,
|
||||
var chainIndex: Int? = null
|
||||
) : RealmModel {
|
||||
internal class SharedSessionEntity : RealmObject {
|
||||
var roomId: String? = null
|
||||
var algorithm: String? = null
|
||||
@Index var sessionId: String? = null
|
||||
@Index var userId: String? = null
|
||||
@Index var deviceId: String? = null
|
||||
@Index var deviceIdentityKey: String? = null
|
||||
var chainIndex: Int? = null
|
||||
|
||||
companion object
|
||||
}
|
||||
|
@ -16,14 +16,11 @@
|
||||
|
||||
package org.matrix.android.sdk.internal.crypto.store.db.model
|
||||
|
||||
import io.realm.RealmModel
|
||||
import io.realm.annotations.RealmClass
|
||||
import io.realm.kotlin.types.RealmObject
|
||||
|
||||
@RealmClass
|
||||
internal open class TrustLevelEntity(
|
||||
var crossSignedVerified: Boolean? = null,
|
||||
var locallyVerified: Boolean? = null
|
||||
) : RealmModel {
|
||||
internal class TrustLevelEntity : RealmObject {
|
||||
var crossSignedVerified: Boolean? = null
|
||||
var locallyVerified: Boolean? = null
|
||||
|
||||
companion object
|
||||
|
||||
|
@ -16,26 +16,25 @@
|
||||
|
||||
package org.matrix.android.sdk.internal.crypto.store.db.model
|
||||
|
||||
import io.realm.RealmList
|
||||
import io.realm.RealmModel
|
||||
import io.realm.annotations.PrimaryKey
|
||||
import io.realm.annotations.RealmClass
|
||||
import io.realm.kotlin.deleteFromRealm
|
||||
import org.matrix.android.sdk.internal.extensions.clearWith
|
||||
import io.realm.kotlin.ext.realmListOf
|
||||
import io.realm.kotlin.types.RealmList
|
||||
import io.realm.kotlin.types.RealmObject
|
||||
import io.realm.kotlin.types.annotations.PrimaryKey
|
||||
|
||||
@RealmClass
|
||||
internal open class UserEntity(
|
||||
@PrimaryKey var userId: String? = null,
|
||||
var devices: RealmList<DeviceInfoEntity> = RealmList(),
|
||||
var crossSigningInfoEntity: CrossSigningInfoEntity? = null,
|
||||
var deviceTrackingStatus: Int = 0
|
||||
) : RealmModel {
|
||||
internal class UserEntity : RealmObject {
|
||||
@PrimaryKey var userId: String? = null
|
||||
var devices: RealmList<DeviceInfoEntity> = realmListOf()
|
||||
var crossSigningInfoEntity: CrossSigningInfoEntity? = null
|
||||
var deviceTrackingStatus: Int = 0
|
||||
|
||||
companion object
|
||||
}
|
||||
|
||||
/*
|
||||
internal fun UserEntity.deleteOnCascade() {
|
||||
devices.clearWith { it.deleteOnCascade() }
|
||||
crossSigningInfoEntity?.deleteOnCascade()
|
||||
deleteFromRealm()
|
||||
}
|
||||
|
||||
*/
|
||||
|
@ -16,9 +16,8 @@
|
||||
|
||||
package org.matrix.android.sdk.internal.crypto.store.db.model
|
||||
|
||||
import io.realm.RealmModel
|
||||
import io.realm.annotations.Index
|
||||
import io.realm.annotations.RealmClass
|
||||
import io.realm.kotlin.types.RealmObject
|
||||
import io.realm.kotlin.types.annotations.Index
|
||||
import org.matrix.android.sdk.api.session.events.model.content.WithHeldCode
|
||||
|
||||
/**
|
||||
@ -28,15 +27,13 @@ import org.matrix.android.sdk.api.session.events.model.content.WithHeldCode
|
||||
* For example, the sender may have blacklisted certain devices or users,
|
||||
* or may be choosing to not send the megolm key to devices that they have not verified yet.
|
||||
*/
|
||||
@RealmClass
|
||||
internal open class WithHeldSessionEntity(
|
||||
var roomId: String? = null,
|
||||
var algorithm: String? = null,
|
||||
@Index var sessionId: String? = null,
|
||||
@Index var senderKey: String? = null,
|
||||
var codeString: String? = null,
|
||||
var reason: String? = null
|
||||
) : RealmModel {
|
||||
internal class WithHeldSessionEntity : RealmObject {
|
||||
var roomId: String? = null
|
||||
var algorithm: String? = null
|
||||
@Index var sessionId: String? = null
|
||||
@Index var senderKey: String? = null
|
||||
var codeString: String? = null
|
||||
var reason: String? = null
|
||||
|
||||
var code: WithHeldCode?
|
||||
get() {
|
||||
|
Loading…
x
Reference in New Issue
Block a user