Fix migration

This commit is contained in:
Valere 2022-07-01 11:08:35 +02:00
parent fb5f0cbd00
commit 08cb6de83d
2 changed files with 11 additions and 4 deletions

View File

@ -107,11 +107,11 @@ internal class OlmInboundGroupSessionWrapper2 : Serializable {
/** /**
* Export the inbound group session keys. * Export the inbound group session keys.
* @param sharedHistory the flag that indicates whether or not the session can be shared
* @param index the index to export. If null, the first known index will be used * @param index the index to export. If null, the first known index will be used
*
* @return the inbound group session as MegolmSessionData if the operation succeeds * @return the inbound group session as MegolmSessionData if the operation succeeds
*/ */
fun exportKeys(sharedHistory: Boolean = false, index: Long? = null): MegolmSessionData? { fun exportKeys(index: Long? = null): MegolmSessionData? {
return try { return try {
if (null == forwardingCurve25519KeyChain) { if (null == forwardingCurve25519KeyChain) {
forwardingCurve25519KeyChain = ArrayList() forwardingCurve25519KeyChain = ArrayList()
@ -133,8 +133,7 @@ internal class OlmInboundGroupSessionWrapper2 : Serializable {
roomId = roomId, roomId = roomId,
sessionId = safeOlmInboundGroupSession.sessionIdentifier(), sessionId = safeOlmInboundGroupSession.sessionIdentifier(),
sessionKey = safeOlmInboundGroupSession.export(wantedIndex), sessionKey = safeOlmInboundGroupSession.export(wantedIndex),
algorithm = MXCRYPTO_ALGORITHM_MEGOLM, algorithm = MXCRYPTO_ALGORITHM_MEGOLM
sharedHistory = sharedHistory
) )
} catch (e: Exception) { } catch (e: Exception) {
Timber.e(e, "## export() : senderKey $senderKey failed") Timber.e(e, "## export() : senderKey $senderKey failed")

View File

@ -23,6 +23,7 @@ import org.matrix.android.sdk.internal.crypto.store.db.deserializeFromRealm
import org.matrix.android.sdk.internal.crypto.store.db.model.CryptoMetadataEntityFields import org.matrix.android.sdk.internal.crypto.store.db.model.CryptoMetadataEntityFields
import org.matrix.android.sdk.internal.crypto.store.db.model.CryptoRoomEntityFields import org.matrix.android.sdk.internal.crypto.store.db.model.CryptoRoomEntityFields
import org.matrix.android.sdk.internal.crypto.store.db.model.OlmInboundGroupSessionEntityFields import org.matrix.android.sdk.internal.crypto.store.db.model.OlmInboundGroupSessionEntityFields
import org.matrix.android.sdk.internal.crypto.store.db.model.OutboundGroupSessionInfoEntityFields
import org.matrix.android.sdk.internal.crypto.store.db.serializeForRealm import org.matrix.android.sdk.internal.crypto.store.db.serializeForRealm
import org.matrix.android.sdk.internal.di.MoshiProvider import org.matrix.android.sdk.internal.di.MoshiProvider
import org.matrix.android.sdk.internal.util.database.RealmMigrator import org.matrix.android.sdk.internal.util.database.RealmMigrator
@ -42,6 +43,13 @@ internal class MigrateCryptoTo017(realm: DynamicRealm) : RealmMigrator(realm, 17
it.setBoolean(CryptoRoomEntityFields.SHOULD_SHARE_HISTORY, false) it.setBoolean(CryptoRoomEntityFields.SHOULD_SHARE_HISTORY, false)
} }
realm.schema.get("OutboundGroupSessionInfoEntity")
?.addField(OutboundGroupSessionInfoEntityFields.SHOULD_SHARE_HISTORY, Boolean::class.java)?.transform {
// We don't have access to the session database to check for the state here and set the good value.
// But for now as it's behind a lab flag, will set to false and force initial sync when enabled
it.setBoolean(OutboundGroupSessionInfoEntityFields.SHOULD_SHARE_HISTORY, false)
}
realm.schema.get("CryptoMetadataEntity") realm.schema.get("CryptoMetadataEntity")
?.addField(CryptoMetadataEntityFields.ENABLE_KEY_FORWARDING_ON_INVITE, Boolean::class.java) ?.addField(CryptoMetadataEntityFields.ENABLE_KEY_FORWARDING_ON_INVITE, Boolean::class.java)
?.transform { obj -> ?.transform { obj ->