You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
...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...
...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
Changes has been tested on an Android device or Android emulator with API 21
UI change has been tested on both light and dark themes
Good catch, but not sure we want to fix it exactly like that.
The CryptoRoomEntity#shouldShareHistory should match what the state of the room is. So we probably want to remove the if (!isShareKeysOnInviteEnabled()) return false check in CryptoStore#shouldShareHistory()
And then we should in prepareNewSessionInRoom() override the flag on the outbound session using the flag. And in ensureOutboundSession we move up the check on the flag instead of just checking the room flag (that just reflects the server side room state)
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution. You have signed the CLA already but the status is still pending? Let us recheck it.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Z-Community-PRIssue is solved by a community member's PR
4 participants
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 brad@beeper.com
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