Commit Graph

9598 Commits

Author SHA1 Message Date
Ivan Enderlin
bdfc300e4c feat(sdk): compute_limited is only useful for the SS proxy.
This patch restricts the call to `compute_limited` to the sliding sync
proxy implementation (aka MCS3575). It is not necessary for the sliding
sync native implementation (aka Simplified MSC3575). The proxy doesn't
implement the `limited` flag, contrary to Synapse. Let's not run
workarounds when we don't need them.
2024-08-12 15:06:01 +02:00
Ivan Enderlin
d143c6198c fix(sdk): Remove SlidingSyncInner::past_positions.
The patch https://github.com/matrix-org/matrix-rust-sdk/pull/2395 has
introduced `SlidingSyncInner::past_positions` as a mechanism to filter
duplicated responses. It was a problem because the sliding sync `ops`
could easily create corrupted states if they were applied more than
once.

Since https://github.com/matrix-org/matrix-rust-sdk/pull/3664/, `ops`
are ignored.

Now, `past_positions` create a problem with the sliding sync native
implementation inside Synapse because `pos` can stay the same between
multiple responses.

While `past_positions` was helpful to fix bugs in the past, it's no
longer necessary today. Moreover, it breaks an invariant about `pos`: we
must consider it as a blackbox. It means we must ignore if a `pos` value
has been received in the past or not. This invariant has been broken for
good reasons, but it now creates new issues.

This patch removes `past_positions`, along with the associated code
(like `Error::ResponseAlreadyReceived` for example).
2024-08-12 14:26:31 +02:00
Ivan Enderlin
35b62a1a4a doc(sdk): Fix a markup.
Even if the visual output is the same, it's semantically better to have
`<a><code>…</code></a>` rather than `<code><a>…</a></code>` I believe.
2024-08-12 13:47:28 +02:00
Ivan Enderlin
704fe6719f feat(sdk): Add a log for must_process_rooms_response.
This patch adds a `trace` log for `must_process_rooms_response`. That's
useful for debugging weird bugs.
2024-08-12 13:47:28 +02:00
Ivan Enderlin
0b9e07a386 chore(sdk): Change visibility of SlidingSyncList::invalidate_sticky_data.
This patch changes the visibility of
`SlidingSyncList::invalidate_sticky_data` from `pub` to `pub(super)`.
This is the only place where it must be accessible from.
2024-08-12 13:47:28 +02:00
Ivan Enderlin
0a28c222f5 test(ui): Improve test_room_subscription.
This patch asserts that when subscribing to a new room, the old room
subscriptions are still present. Is it the behaviour we want? Probably
not, but this is the standard behaviour right now, and we need to assert
it.
2024-08-12 13:47:28 +02:00
Richard van der Hoff
31dbca6c28 testing: create ruma_response_from_json
We had *two* copies of `response_from_file`, and all calls to them were always
immediately followed by an operation to parse the response as a Ruma response
object.

We can save a whole lot of boilerplate with a generic function that wraps the
json into an HTTP response *and* parses it into a Ruma object.
2024-08-12 12:39:02 +01:00
Richard van der Hoff
f96e82f833 indexeddb: Future-proofing: accept any db schema version up to 99
... so that next time we make a non-breaking change to the schema, it doesn't
break rollback
2024-08-12 12:37:56 +01:00
Richard van der Hoff
f2792801c3 indexeddb: Add missing do_schema_upgrade call from v11 migration
We weren't updating the database schema version immediately after the v10 -> v11
migration. This was fine in practice, because (a) for now, there is no v12
migration so we ended up setting the schema version immediately anyway; (b) the
migration is idempotent.

However, it's inconsistent with the other migrations and confusing, and is
about to make my test fail, so let's clean it up.
2024-08-12 12:37:56 +01:00
Benjamin Bouvier
a0c8b71236 refactor(sdk): merge Room::event and Room::event_with_config
It's better to have fewer public APIs, especially when there's little
annoyance to have it. We could use a request builder that converts into
a Future, too, but considering there's only a single optional parameter,
it's fine to include it in the function's signature.
2024-08-12 11:51:54 +02:00
Erik Johnston
101f6bd57b Sync: Don't spuriously show spinner
We should only show the spinner if the *first* sliding sync request is
taking a while. If we have received some data and the second request
takes a while, that is OK.

For the state transition of `Init -> SettingUp` this is handled
correctly, however for `Terminated -> Recovering -> Running` we waited
until the second request returned before hiding the sync spinner. This
meant that if the first request returned quickly the app would show new
data and *then* the sync spinner would show (if the second request took
time).

This situation occurs frequently with the new SSS API, where if all the
new data was returned in the first sync then the second sync would
block waiting for new data, triggering the sync spinner.
2024-08-12 11:47:18 +02:00
Benjamin Bouvier
fa394fc45b test: remove unused TestClientBuilder::http_proxy method 2024-08-12 11:44:34 +02:00
Ivan Enderlin
16ca282ae4 chore(ui): Add logs inside RoomListService::sync.
This patch adds logs inside the `RoomListService::sync` method to know
what are the current states.
2024-08-12 10:03:22 +02:00
Ivan Enderlin
be404f6666 feat(sdk): Subscribe to many rooms only via Sliding Sync.
This patch changes the `SlidingSync::subscribe_to_room` method to
`subscribe_to_rooms`. Note the plural form. It's now mandatory to
subscribe to a set of rooms. The idea is to avoid calling this method
repeatedly. Why? Because each time the method is called, it sends a
`SlidingSyncInternalMessage` of kind `SyncLoopSkipOverCurrentIteration`,
i.e. it cancels the in-flight sliding sync request, to start over with
a new one (with the new room subscription). A problem arises when the
async runtime (here, Tokio) is busy: in this case, the internal message
channel can be filled pretty easily because its size is 8. Messages
are not consumed as fast as they are inserted. By changing this API:
subscribing to multiple rooms will result in a single internal message,
instead of one per room.

Consequently, the rest of the patch moves the `subscribe` method of
`room_list_service::Room` to `room_list_service::RoomListService`
because it now concerns multiple rooms instead of a single one.
2024-08-09 11:58:59 +03:00
Stefan Ceriu
89ce8870a9 ffi: provide manual cancellation mechanism for identity/cross-signing reset handles
- works around swift issue where nil-ing the handle is not enough for it to get cancelled
2024-08-09 10:27:56 +03:00
Ivan Enderlin
70f46d48af chore(ffi): More idiomatic format!. 2024-08-08 17:54:49 +02:00
Timo
58f4e2b1ad FFI Element Call: Fix the permission list returned by the get_element_call_required_permissions ffi function. 2024-08-08 17:54:49 +02:00
Damir Jelić
58c35ee507 Add the rust-crypto-reviewers to the code owners for the crypto crate 2024-08-08 14:51:30 +02:00
Damir Jelić
40c347846e docs: Mention that the custom types in the crypto crate implement zeroize 2024-08-08 14:04:11 +02:00
Richard van der Hoff
9c809b900d Merge pull request #3813 from matrix-org/rav/split_machine_tests
crypto: split up the `machine.rs` behemoth
2024-08-08 12:00:39 +01:00
Damir Jelić
a03893ee3f ci: Enable CI for draft PRs (#3815)
Our CI used to be quite slow and used up a lot of CI time, so as an
optimization we disabled CI for draft PRs.

This is a bit annoying since people want to open draft PRs to check if
CI passes, but without triggering any review requests.

Since our CI is nowadays a bit more efficient let's see if we can enable
it for draft PRs.
2024-08-08 12:58:51 +02:00
Richard van der Hoff
045374c604 Merge remote-tracking branch 'origin/main' into rav/split_machine_tests 2024-08-08 11:44:12 +01:00
Richard van der Hoff
f3fe06be7d Merge pull request #3795 from matrix-org/valere/invisible_crypto/verification_pin
Crypto | Add support for verified identities change detection.
2024-08-08 11:10:47 +01:00
Richard van der Hoff
2220973adc crypto: move room_settings tests to their own file 2024-08-07 17:20:02 +01:00
Richard van der Hoff
d8b0b2e097 crypto: move encrypted to-device tests to new file 2024-08-07 17:18:52 +01:00
Richard van der Hoff
93f6bdecb3 crypto: move decryption verification state tests to a new file 2024-08-07 17:17:51 +01:00
Richard van der Hoff
85b74edf80 crypto: move interactive verification tests to a new file 2024-08-07 17:17:02 +01:00
Richard van der Hoff
6f5442c5ce crypto: Move some olm-related tests to a separate file 2024-08-07 17:15:45 +01:00
Richard van der Hoff
18e27f3090 crypto: move OlmMachine tests to a separate file 2024-08-07 17:05:47 +01:00
Richard van der Hoff
066fdf99c3 crypto: Move create_session test helper to test_helpers 2024-08-07 17:02:47 +01:00
Richard van der Hoff
2c0d858833 crypto: Pull out OlmMachine test helpers to a new module 2024-08-07 16:10:26 +01:00
Richard van der Hoff
0b5f9aec5e crypto: promote machine module to directory 2024-08-07 16:08:56 +01:00
Valere
1b05380b60 Crypto: Verified identity changes - Add API at UserIdentity level + test 2024-08-07 15:06:19 +02:00
Valere
072b5d5605 Fix typo in method name 2024-08-07 13:36:20 +02:00
Valere
7e9f4fc5a0 CodeReview: Clarify comment 2024-08-07 13:34:12 +02:00
Valere
2e410e5d94 CodeReview: rename verification_latch to previously verified 2024-08-07 13:34:12 +02:00
Valere
d81b12f389 Review: Fix false postitive typo in b64 string 2024-08-07 13:34:12 +02:00
Valere
58c4075ff5 Review: CI fix identity serialization test 2024-08-07 13:34:12 +02:00
Valere
3c9ae33be1 crypto: Verified identity changes - Migration of existing data 2024-08-07 13:34:12 +02:00
Valere
c171c518c6 crypto: Verified identity changes Fix test with memory store
Clone of identities prevent detect changes due shared Arc. Force serializing/deserializing
2024-08-07 13:32:55 +02:00
Valere
20f717ec31 crypto: Verified Identity changes - Update latch on own trust change 2024-08-07 13:32:55 +02:00
Valere
0e01b1d93c crypto: Verified identity changes - Update latch on identity update 2024-08-07 13:29:58 +02:00
Valere
3d3f93a33d crypto: Verified identity changes TDD 2024-08-07 13:29:57 +02:00
Valere
b4fe3059c3 crypto: Remember and detect verified identity changes for #1129 2024-08-07 13:29:57 +02:00
Jorge Martín
57963dcf36 ffi: add method for the ClientBuilder to provide a RequestConfig for the client 2024-08-07 11:48:34 +02:00
Jorge Martín
7d9fdc4f05 sdk-ui: add fn Room::event_with_config
This method works the same as `Room::event` but you can provide a custom `RequestConfig` to it.

It's especially useful for the pinned events timeline, since we need a max number of retries and a max number of concurrent requests. With this we can remove some unnecessary complexity.
2024-08-07 11:48:15 +02:00
Jorge Martín
1c4f035c99 sdk-ui: reverse (again) the order in the pinned events timeline
This way it matches the rest of timelines in the SDK, I reversed it here because I didn't realise most clients just do this reversal of ordering themselves. As they do, they need the same order for this timeline too to be able to reuse their existing logic.
2024-08-06 19:33:00 +02:00
Doug
71e4f60fa5 chore: Update the human readable description for the SentInClear shield. 2024-08-06 17:22:38 +03:00
Damir Jelić
c3848ca016 crypto: Update the changelog 2024-08-06 15:10:13 +02:00
Damir Jelić
a74f6bcc3f Add the Olm Session cache back in the CryptoStoreWrapper 2024-08-06 15:10:13 +02:00