element-hq / element-hq/element-android
Fully import the Megolm sessions to the OlmMachine
- Dominant language
- Kotlin
- Stars
- 3.7k
- Forks
- 917
- PR merge metrics
- No merged PRs in 30d
Description
The Megolm sessions are imported in a lazy manner, at this place: https://github.com/element-hq/element-android/blob/main/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/crypto/RustCryptoService.kt#L514 👍
```kotlin
val legacy = tryOrNull("Failed to access legacy crypto store") {
cryptoStore.getInboundGroupSession(sessionId, senderKey.orEmpty())
}
if (legacy == null || olmMachine.importRoomKey(legacy).isFailure) {
perSessionBackupQueryRateLimiter.tryFromBackupIfPossible(sessionId, roomId)
}
```
First point: this code does not remove the existing key from the Realm DB. This is not a big deal, but it will impact the coming migration, since the key will be imported again.
We need to to migrate all the existing Megolm sessions, because Element X will not be able to access the Realm Database. Context: https://github.com/element-hq/element-x-android/issues/86
The import can be a long running task, done in background (so no need to do it in a Db migration for instance).
### Definition of done
When the application is upgraded with a build including the code change, all the keys are migrated after a few minutes (hours is acceptable), and the Megolm Sessions table is emptied.
Contributor guide
Assessment
This issue has not been assessed yet.