Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix JSONDictionary of keys query responses #1707

Merged
merged 1 commit into from
Feb 2, 2023
Merged

Conversation

Anderas
Copy link
Contributor

@Anderas Anderas commented Feb 2, 2023

When downloading user keys via keys/query we sometimes use downloadByChunks method that makes several HTTP requests and combines the result into a single MXKeysQueryResponse. The Crypto V2 relies on getting the value of this response via JSONDictionary property, however this property was previously just returning whatever initial value was used to create it, and is nil when combining multiple responses together.

To solve this we cannot rely on stored property but rather have to compute the JSONDictionary out of the current values of the response. Additionally there was a minor bug in downloadByChunks that would trigger this problem even if we are downloading exactly chunk-sized number of users

@Anderas Anderas requested review from a team and flescio and removed request for a team February 2, 2023 10:11
@@ -35,7 +35,7 @@ public extension MXRestClient {
failure: @escaping (_ error: NSError?) -> Void) -> MXHTTPOperation {

// Do not chunk if not needed
if users.count < chunkSize {
if users.count <= chunkSize {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Naughty naughty. Will write a test for this in a separate PR as it requires some integration test stubbing

@codecov
Copy link

codecov bot commented Feb 2, 2023

Codecov Report

Base: 17.40% // Head: 37.32% // Increases project coverage by +19.91% 🎉

Coverage data is based on head (fa7334b) compared to base (f3d0084).
Patch coverage: 4.41% of modified lines in pull request are covered.

Additional details and impacted files
@@             Coverage Diff              @@
##           develop    #1707       +/-   ##
============================================
+ Coverage    17.40%   37.32%   +19.91%     
============================================
  Files          610      611        +1     
  Lines        95428    95876      +448     
  Branches     40198    41447     +1249     
============================================
+ Hits         16613    35785    +19172     
+ Misses       78309    59043    -19266     
- Partials       506     1048      +542     
Impacted Files Coverage Δ
...trixSDK/Crypto/CryptoMachine/MXCryptoMachine.swift 14.14% <0.00%> (+14.14%) ⬆️
...ests/JSONModels/MXKeysQueryResponseUnitTests.swift 0.00% <0.00%> (ø)
MatrixSDK/JSONModels/MXJSONModels.m 27.92% <56.00%> (+21.29%) ⬆️
MatrixSDK/Categories/MXRestClient+Extensions.swift 22.80% <100.00%> (+22.80%) ⬆️
...o/Algorithms/RoomEvent/MXRoomEventEncryption.swift 83.21% <100.00%> (+0.37%) ⬆️
MatrixSDK/Crypto/Devices/Data/MXDeviceInfo.m 93.67% <100.00%> (+67.24%) ⬆️
...o/Algorithms/RoomEvent/MXRoomEventDecryption.swift 54.80% <0.00%> (-0.54%) ⬇️
MatrixSDK/Utils/Media/MXMediaManager.m 1.88% <0.00%> (+0.47%) ⬆️
MatrixSDK/Contrib/Swift/MXRestClient.swift 2.22% <0.00%> (+0.74%) ⬆️
...gations/LocationSharing/MXBeaconAggregations.swift 4.44% <0.00%> (+1.26%) ⬆️
... and 196 more

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

☔ View full report at Codecov.
📢 Do you have feedback about the report comment? Let us know in this issue.

Copy link
Contributor

@flescio flescio left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@Anderas Anderas merged commit f4d2c8b into develop Feb 2, 2023
@Anderas Anderas deleted the andy/query_fixes branch February 2, 2023 13:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants