Commit Graph

9633 Commits

Author SHA1 Message Date
Ivan Enderlin
7e2c773d21 chore(base): Move RoomNotificationMode into matrix-sdk-base.
This patch moves the `RoomNotificationMode` type from `matrix-sdk`
to `matrix-sdk-base` because it's going to be shared across multiple
crates.
2024-08-15 14:51:16 +03:00
Jorge Martín
6becbf61c9 fixup! Fixes after rebase 2024-08-14 17:38:24 +02:00
Jorge Martín
1155f75612 fixup! fix review comments 2024-08-14 17:38:24 +02:00
Jorge Martín
5cd29830a3 fixup! Fix clippy after merge 2024-08-14 17:38:24 +02:00
Jorge Martín
34370b1525 fixup! Fix test 2024-08-14 17:38:24 +02:00
Jorge Martín
1132074ae0 sdk-base: Make sure we only send a notable membership update when membership does change 2024-08-14 17:38:24 +02:00
Jorge Martín
e5af5a32fa sdk-base: Add RoomInfoNotableUpdateReasons::MEMBERSHIP
This fixes joined rooms not being bumped to the top of the timeline and left rooms not disappearing from the room list.
2024-08-14 17:38:24 +02:00
Richard van der Hoff
1e8dd5dd41 crypto: Update changelog 2024-08-14 14:57:42 +01:00
Richard van der Hoff
5431c0fdd6 crypto: test: add tests for error_on_verified_user_problem 2024-08-14 14:57:42 +01:00
Richard van der Hoff
a240b87ba6 crypto: test: factor out redundant variable
This thing was confusing. What is "legacy" about it?
2024-08-14 14:57:42 +01:00
Richard van der Hoff
324cf2e007 crypto: test: factor out create_test_outbound_group_session helper 2024-08-14 14:57:42 +01:00
Valere
66142317d4 crypto: key sharing error for verified user with unverified devices 2024-08-14 14:57:42 +01:00
Richard van der Hoff
f66c74e878 crypto: extend CollectionStrategy::DeviceBasedStrategy
Add (as yet unimplemented) `error_on_verified_user_problem` option
2024-08-14 14:57:42 +01:00
Richard van der Hoff
1862a3e254 crypto: change EncryptionSettings::new to take a CollectStrategy
Again, the list of boolean arguments is confusing.
2024-08-14 14:57:42 +01:00
Richard van der Hoff
dadc85c4fc crypto: remove CollectStrategy::new_device_based
The list of boolean arguments is confusing. We may as well just construct the
`DeviceBasedStrategy` directly.
2024-08-14 14:57:42 +01:00
Richard van der Hoff
d8c1094939 crypto: add OwnUserIdentityData::is_identity_verified
... and use it to remove a bit of duplicated code.
2024-08-14 14:57:42 +01:00
Richard van der Hoff
ace937fcee crypto: rafactor split_recipients_withhelds_for_user
Use a for loop rather than `partition_map`. We're about to add a third list, so
partition_map won't work.

(partition_map ends up using Vec::push under the hood, so this is pretty much
equivalent.)
2024-08-14 14:57:42 +01:00
Richard van der Hoff
1e58c0382c crypto: minor cleanups in is_session_overshared_for_user 2024-08-14 14:57:42 +01:00
Valere
ce95cc06e0 crypto: extract function that checks if session is shared too much 2024-08-14 14:57:42 +01:00
Andrew Ferrazzutti
3803792518 rtc: Handle non-MXID call member event state keys (#3836)
Update Ruma dependency to expect call membership state events with state
keys that are arbitrary strings, not just pure MXIDs.

When a call membership state key does not exactly match the format of an
MXID, treat it as a valid state key if it starts with an MXID followed
by an underscore, with that MXID designating the owner of the event.

(The state key may also be optionally prefixed with an underscore, which
is permitted as a way to bypass pre-MSC3757 authorization rules against
sending state events with state keys that do not exactly match the
sender's MXID.)

---------

Signed-off-by: Andrew Ferrazzutti <andrewf@element.io>
Co-authored-by: Benjamin Bouvier <public@benj.me>
Co-authored-by: Benjamin Bouvier <benjamin@bouvier.cc>
2024-08-14 08:43:02 +00:00
Richard van der Hoff
4ece38af4f test: document methods in PreviouslyVerifiedTestData 2024-08-13 16:38:58 +01:00
Richard van der Hoff
4baa82d3a6 test: add new methods for device IDs 2024-08-13 16:38:58 +01:00
Richard van der Hoff
8b01e3e209 test: make internal functions private 2024-08-13 16:38:58 +01:00
Richard van der Hoff
4a69cc9110 test: inline device_keys_payload_bob_unsigned_device
This is only used in one place, so is a bit pointless.
2024-08-13 16:38:58 +01:00
Benjamin Bouvier
766786e2f1 pinned events(refactor): get rid of the PinnedEventCache
This commit makes use of the `RoomEventCache` instead of the
`PinnedEventCache` for a room, so the latter can be removed.
2024-08-13 17:17:16 +02:00
Benjamin Bouvier
e67e2289e2 event cache(refactor): use a map keyed by event id for retrieving events
And add unit tests.
2024-08-13 17:17:16 +02:00
Benjamin Bouvier
5954ee18b7 pinned events(refactor): rename event_with_config to fetch_event
The `with_config` is now redundant, and `fetch` makes it clear it's
hitting network.
matrix-sdk-ffi/20240813
2024-08-12 16:01:39 +02:00
Benjamin Bouvier
e15ddf6ad9 pinned events(refactor): simplify handling of AddTimelineEvents
The timeline already listens to changes to the pinned events list (via a
stream), so there's no need to fully reload all the pinned events every
time we receive a new event that's pinned. Technically it may avoid one
or a few lookups, but this is cheap and a subsequent commit/PR will
merge the pinned event cache into the event cache.
2024-08-12 16:01:39 +02:00
Benjamin Bouvier
19b6495f2b pinned events(refactor) misc tiny refactorings and renamings 2024-08-12 16:01:39 +02:00
Benjamin Bouvier
0ba6adbf34 pinned events(chore): add doc comments 2024-08-12 16:01:39 +02:00
Benjamin Bouvier
3886a55ad8 pinned events(chore): add licence header to pinned_events_loader.rs 2024-08-12 16:01:39 +02:00
Benjamin Bouvier
8f59f45183 pinned events(refactor): don't store max_concurrent_requests as a field
since it's used only once
2024-08-12 16:01:39 +02:00
Benjamin Bouvier
a12a244a89 pinned events(refactor): lower logs from info to debug 2024-08-12 16:01:39 +02:00
Benjamin Bouvier
f3587a44dc pinned events(refactor): fetch all the pinned events concurrently
Also log the reason why one couldn't be fetched, instead of discarding
silently.
2024-08-12 16:01:39 +02:00
Benjamin Bouvier
c76ea95f65 pinned events(refactor): sort loaded pinned events in place
Instead of creating a collection, then using itertools to sort it, then
allocating a new vector from that.
2024-08-12 16:01:39 +02:00
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