Respect isShareKeysOnInviteEnabled() flag when creating new outbound megolm sessions #8540
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Signed-off-by: Brad Murray [email protected]
Type of change
Content
This code...
https://github.com/vector-im/element-android/blob/cf366f7a9c1e83284e91702400fde2371af2b02a/matrix-sdk-android/src/kotlinCrypto/java/org/matrix/android/sdk/internal/crypto/algorithms/megolm/MXMegolmEncryption.kt#L211
...is comparing what's currently in the CryptoStore for the room to the current session were using and rotating the session if they disagreed about sharing history. When checking the CryptoStore for the current room state, the feature flag is respected...
https://github.com/vector-im/element-android/blob/77a6c67ea6adb8a599f9f521e23c0b374fdca341/matrix-sdk-android/src/kotlinCrypto/java/org/matrix/android/sdk/internal/crypto/store/db/RealmCryptoStore.kt#L760
...but when we were creating a new session as a result we aren't checking the state of the flag, meaning we'll create new sessions with shouldShareHistory = true. This will lead to the session still mismatching and continuing to get unecessarily rotated. This PR respects the feature flag so that new sessions will be created with sharedHistory = false if the flag is disabled.
Motivation and context
We shouldn't unecessarily rotate the megolm keys more than necessary when this feature flag is off, which is the default setting.
Checklist