Skip to content

Commit 08cb6de

Browse files
committed
Fix migration
1 parent fb5f0cb commit 08cb6de

File tree

2 files changed

+11
-4
lines changed

2 files changed

+11
-4
lines changed

matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/crypto/model/OlmInboundGroupSessionWrapper2.kt

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -107,11 +107,11 @@ internal class OlmInboundGroupSessionWrapper2 : Serializable {
107107

108108
/**
109109
* Export the inbound group session keys.
110-
* @param sharedHistory the flag that indicates whether or not the session can be shared
111110
* @param index the index to export. If null, the first known index will be used
111+
*
112112
* @return the inbound group session as MegolmSessionData if the operation succeeds
113113
*/
114-
fun exportKeys(sharedHistory: Boolean = false, index: Long? = null): MegolmSessionData? {
114+
fun exportKeys(index: Long? = null): MegolmSessionData? {
115115
return try {
116116
if (null == forwardingCurve25519KeyChain) {
117117
forwardingCurve25519KeyChain = ArrayList()
@@ -133,8 +133,7 @@ internal class OlmInboundGroupSessionWrapper2 : Serializable {
133133
roomId = roomId,
134134
sessionId = safeOlmInboundGroupSession.sessionIdentifier(),
135135
sessionKey = safeOlmInboundGroupSession.export(wantedIndex),
136-
algorithm = MXCRYPTO_ALGORITHM_MEGOLM,
137-
sharedHistory = sharedHistory
136+
algorithm = MXCRYPTO_ALGORITHM_MEGOLM
138137
)
139138
} catch (e: Exception) {
140139
Timber.e(e, "## export() : senderKey $senderKey failed")

matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/crypto/store/db/migration/MigrateCryptoTo017.kt

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ import org.matrix.android.sdk.internal.crypto.store.db.deserializeFromRealm
2323
import org.matrix.android.sdk.internal.crypto.store.db.model.CryptoMetadataEntityFields
2424
import org.matrix.android.sdk.internal.crypto.store.db.model.CryptoRoomEntityFields
2525
import org.matrix.android.sdk.internal.crypto.store.db.model.OlmInboundGroupSessionEntityFields
26+
import org.matrix.android.sdk.internal.crypto.store.db.model.OutboundGroupSessionInfoEntityFields
2627
import org.matrix.android.sdk.internal.crypto.store.db.serializeForRealm
2728
import org.matrix.android.sdk.internal.di.MoshiProvider
2829
import org.matrix.android.sdk.internal.util.database.RealmMigrator
@@ -42,6 +43,13 @@ internal class MigrateCryptoTo017(realm: DynamicRealm) : RealmMigrator(realm, 17
4243
it.setBoolean(CryptoRoomEntityFields.SHOULD_SHARE_HISTORY, false)
4344
}
4445

46+
realm.schema.get("OutboundGroupSessionInfoEntity")
47+
?.addField(OutboundGroupSessionInfoEntityFields.SHOULD_SHARE_HISTORY, Boolean::class.java)?.transform {
48+
// We don't have access to the session database to check for the state here and set the good value.
49+
// But for now as it's behind a lab flag, will set to false and force initial sync when enabled
50+
it.setBoolean(OutboundGroupSessionInfoEntityFields.SHOULD_SHARE_HISTORY, false)
51+
}
52+
4553
realm.schema.get("CryptoMetadataEntity")
4654
?.addField(CryptoMetadataEntityFields.ENABLE_KEY_FORWARDING_ON_INVITE, Boolean::class.java)
4755
?.transform { obj ->

0 commit comments

Comments
 (0)