Commit Graph

9917 Commits

Author SHA1 Message Date
Johannes Marbach e16ca9d8ba ffi: default to reldbg when building iOS bindings
Relates to: #4009
Signed-off-by: Johannes Marbach <n0-0ne+github@mailbox.org>
2024-09-19 08:03:36 +02:00
Benjamin Bouvier 746d7e13ab tests: change strategy for test_ensure_max_concurrency_is_observed 2024-09-18 17:34:24 +02:00
Benjamin Bouvier 1b4f665d99 integration tests: update instructions (#4017)
- explain what these tests are
- mention that it's sometimes needed to rebuild the synapse image

---------

Signed-off-by: Benjamin Bouvier <benjamin@bouvier.cc>
Co-authored-by: Ivan Enderlin <ivan@mnt.io>
2024-09-18 14:45:33 +00:00
Jorge Martín 7d1bbfaa32 sdk-base: split handle_account_data and process_direct_rooms
This removes a couple of TODOs in the codebase.
matrix-sdk-ffi/20240918
2024-09-18 08:16:56 +02:00
Timo 8119697ef0 MatrixRTC: Fix different devices from the same user overwriting the room info state event. 2024-09-17 17:02:06 +02:00
Jorge Martín decdd6f47e crypto-ffi: update the x86-64 Android workaround to match matrix-sdk-ffi
This workaround was applied to `matrix-sdk-ffi` and it should be used here too
2024-09-17 16:44:52 +02:00
Ivan Enderlin 72febaee57 feat(base): Increase the room_info_notable_update_sender capacity.
This broadcast channel can easily be overflowed if more than 100 updates
arrive at the time. This patch extends the capacity to 2^16 - 1.
2024-09-17 16:37:23 +02:00
Ivan Enderlin 7a2728f8b5 feat(ui): Add logs when RoomList entries receive a lag.
This patch updates `merge_stream_and_receiver` to display an `error!`
when the room info receiver reads an error, like `Closed` or `Lagged`.
This is helpful when debugging.
2024-09-17 16:37:23 +02:00
Damir Jelić f576c72ef8 crypto: Avoid deep copying the OlmMachine when creating a NotificationClient
The NotificationClient, responsible for handling, fetching, and
potentially decrypting events received via push notifications, creates a
copy of the main Client object.

During this process, the Client object is adjusted to use an in-memory
state store to prevent concurrency issues from multiple sync loops
attempting to write to the same database.

This copying unintentionally recreated the OlmMachine with fresh data
loaded from the database. If both Client instances were used for syncing
without proper cross-process locking, forks of the vodozemac Account and
Olm Sessions could be created and later persisted to the database.

This behavior can lead to the duplication of one-time keys, cause
sessions to lose their ability to decrypt messages, and result in the
generation of undecryptable messages on the recipient’s side.
2024-09-16 18:27:31 +02:00
Damir Jelić 1429c1a06a test: Confirm that the notification client doesn't create duplicate one-time keys 2024-09-16 18:27:31 +02:00
Damir Jelić b7ce2dc7e6 chore: Fix a clippy warning 2024-09-16 17:58:29 +02:00
Benjamin Bouvier ea9da3bdad tests: increase timeout duration when awaiting a timeline update 2024-09-16 17:35:42 +02:00
Stefan Ceriu a1bb7c0acc sdk: add account deactivation tests 2024-09-16 17:52:39 +03:00
Stefan Ceriu ea4b9635c9 ffi: add another method that tells the client if account deactivation is supported
- i.e. only works for `m.login.password`
2024-09-16 17:52:39 +03:00
Stefan Ceriu 5b79a9843e ffi: expose method to allow user account deactivate for m.login.password based accounts 2024-09-16 17:52:39 +03:00
Benjamin Bouvier abbe2ec523 tests: increase timeout duration for await_room_remote_echo
Fixes #4003, or so I suspect. The integration tests run in code coverage
can be quite slow, so we can't put timeouts this low.
2024-09-16 14:29:57 +02:00
Benjamin Bouvier 965390cbdc notification client: use the membership state to match an invite 2024-09-16 14:02:07 +02:00
Ivan Enderlin 119bee66ce feat(sdk,ui): SlidingSync::subscribe_to_rooms has a new cancel_in_flight_request argument.
This patch adds a new `cancel_in_flight_request` argument to
`SlidingSync::subscribe_to_rooms`, which tells the method cancel the
in-flight request if any.

This patch also updates `RoomListService::subscribe_to_rooms` to turn
this new argument to `true` if the state machine isn't in a “starting”
state.

The problem it's solving is the following:

* some apps starts the room list service
* a first request is sent with `pos = None`
* the server calculates a new session (which can be expensive)
* the app subscribes to a set of rooms
* a second request is immediately sent with `pos = None` again
* the server does possibly NOT cancel its previous calculations, but
  starts a new session and its calculations

This is pretty expensive for the server. This patch makes so that the
immediate room subscriptions will be part of the second request, with
the first request not being cancelled.
2024-09-16 12:18:07 +02:00
Ivan Enderlin 4fd4410f4a chore: Update to ruma/ruma. 2024-09-16 12:08:15 +02:00
Ivan Enderlin af390328b5 Revert "chore(ui,ffi): Remove the RoomList::entries method."
This reverts commit 98a3a0b3c4.
2024-09-16 12:02:03 +02:00
Ivan Enderlin 98a3a0b3c4 chore(ui,ffi): Remove the RoomList::entries method.
This method is now private inside `matrix_sdk_ui` and removed
from `matrix_sdk_ffi`. This method is returning a stream of rooms,
but updates on rooms won't update the stream (only new rooms
will be seen on the stream). Nobody uses it as far as I know, and
`entries_with_dynamic_adapters` is the real only API we want people
to use.
2024-09-16 11:50:11 +02:00
Jorge Martín aa92e26342 sdk-base: fix handle_account_data behaviour
Handle the account data in the response if not empty, otherwise use the cached one.
2024-09-16 11:20:47 +02:00
Jorge Martín dd13fe6b4e sdk-base: use updated account data for processing direct rooms 2024-09-16 11:20:47 +02:00
Doug a9ed62284e ffi: Expose the server URL to the app too. 2024-09-13 19:32:08 +03:00
Doug 2532c5227f ffi: Add the registration helper URL to the ElementWellKnown file. 2024-09-13 18:37:45 +03:00
Richard van der Hoff 72cc2bd60c crypto: Include megolm ratchet index in logging span fields
This field is helpful as it tells us the sequence number of the message in the
megolm session, which gives us a clue about how long it will have been since
the session should have been shared with us.
2024-09-13 12:18:52 +01:00
Benjamin Bouvier 2408df8bf5 multiverse: highlight which rooms are DMs in the list matrix-sdk-ffi/20240913 2024-09-12 14:58:59 +02:00
Jorge Martín 5827bb7ab3 sdk-ui: fix typo in TimelineState::replace_with_remove_events matrix-sdk-crypto-ffi-0.4.3 2024-09-12 13:21:39 +02:00
Jorge Martín 25111ac9eb sdk-ui: make SlidingSyncRoom not needed in RoomListItem::default_room_timeline_builder.
Having initial items shouldn't be mandatory to create a timeline, the timeline can also be empty.
2024-09-12 13:21:39 +02:00
Jorge Martín 6ae7d3c017 ffi: add FFI fn for Client::await_room_remote_echo(&room_id) 2024-09-12 13:21:39 +02:00
Jorge Martín bbe16db94c sdk: add Client::await_room_remote_echo(&room_id)
This fn will loop until it finds an at least partially synced room with the given id. It uses the `ClientInner::sync_beat` listener to wait until the next check is needed.
2024-09-12 13:21:39 +02:00
Jorge Martín f8961a4382 sdk-base: add Room::is_state_partially_or_fully_synced()
This new fn is used to check when a room is at least partially synced, which seems to be the case with SSS.
2024-09-12 13:21:39 +02:00
Damir Jelić 9e7ab635c6 bindings: Expose the PkEncryption stuff in the crypto crate bindings (#3971) 2024-09-12 09:54:46 +00:00
Damir Jelić a024c010ce chore: Remove the olm-rs dep now that PkEncryption stuff has moved to vodozemac 2024-09-12 10:35:28 +02:00
Damir Jelić 3555474cad crypto: Bump the vodozemac version and remove the PkEncryption compat module
The PkEncryption support now lives inside of vodozemac so no need to
keep our own copy around.
2024-09-11 17:03:50 +02:00
Ivan Enderlin 2b3ad86869 feat(ui): all_rooms in RoomListService requires m.room.canonical_name.
This patch adds `m.room.canonical_name` in the `required_state` of the
`all_rooms` list defined by `RoomListService`.

This is useful to better compute the room name in a more robust way.
2024-09-11 16:06:03 +02:00
Ivan Enderlin 075f3fa9d2 feat(ffi): Add RoomInfo::creator.
This patch adds the `matrix_sdk_ffi::RoomInfo::creator` field that
simply copies the value from `matrix_sdk_base::Room::creator()`.
2024-09-11 15:19:41 +02:00
Ivan Enderlin 47c7d05499 feat(base): Add Room::creator().
This patch adds `Room::creator()` to expose the value from
`RoomInfo::creator()`.
2024-09-11 15:19:41 +02:00
Jorge Martín 4b970e879f sdk: ensure sync_beat is only notified with a successful sync response matrix-sdk-ffi/20240911 2024-09-11 12:46:32 +02:00
Jorge Martín cc0dfd62e7 sdk: notify when a sync response is received by SlidingSync
Previously this was only done in `Client::sync_once`, which made `ClientInner::sync_beat` not that useful.
2024-09-11 12:46:32 +02:00
Jorge Martin Espinosa 31e6df7234 timeline: unify edit and edit_poll functions (#3951)
## Changes

Takes care of [this
TODO](https://github.com/matrix-org/matrix-rust-sdk/blob/9df1c480795c42afcee39e4c7e553d5a927a2680/crates/matrix-sdk-ui/src/timeline/mod.rs#L520).

- sdk & sdk-ui: unify `Timeline::edit` and `Timeline::edit_polls`, the
new fn takes an `EditedContent` parameter now, which includes a
`PollStart` case too.
- ffi: also unify the FFI fns there, using `PollStart` and a new
`EditContent` enum that must be passed from the clients like:

```kotlin
val messageContent = MessageEventContent.from(...)
timeline.edit(event, EditedContent.RoomMessage(messageContent))
```

Since the is mainly about changing the fns signatures I've reused the
existing tests, including one that used `edit_poll` that now uses the
new fn.

---------

Co-authored-by: Benjamin Bouvier <benjamin@bouvier.cc>
2024-09-11 08:50:51 +00:00
Ivan Enderlin 2576042194 chore(sdk): Add an info log in sliding sync. 2024-09-11 10:40:59 +02:00
Ivan Enderlin a3ae9dca75 doc(crypto): Improve documentation. 2024-09-11 10:40:59 +02:00
Ivan Enderlin 6e36111462 fix(sdk): Mark tracked users as dirty when the SS connection is reset.
There is a non-negligible difference MSC3575 and MSC4186 in how the
`e2ee` extension works. When the client sends a request with no `pos`:

* MSC3575 returns all device lists updates since the last request
  from the device that asked for device lists (this works similarly to
  to-device message handling),

* MSC4186 returns no device lists updates, as it only returns changes
  since the provided `pos` (which is `null` in this case); this is in
  line with sync v2.

Therefore, with MSC4186, the device list cache must be marked as to be
re-downloaded if the `since` token is `None`, otherwise it's easy to
miss device lists updates that happened between the previous request and
the new “initial” request.
2024-09-11 10:40:59 +02:00
Ivan Enderlin b7bde3cabe feat(crypto): Implement OldMachine::mark_all_tracked_users_as_dirty.
This patch adds the `OldMachine::mark_all_tracked_users_as_dirty`.

This patch rewrites a bit `OlmMachine::new_helper` by extracting some
piece of it inside `OlmMachine::new_helper_prelude`. With that, we
can rewrite `OlmMachine::migration_post_verified_latch_support` to use
`IdentityManager::mark_all_tracked_users_as_dirty`.
This latter is the shared implementation with
`OlmMachine::mark_all_tracked_users_as_dirty`.

This patch adds a test for `OlmMachine:mark_all_tracked_users_as_dirty`.
2024-09-11 10:40:59 +02:00
Benjamin Bouvier cb825864b9 event cache: reset paginator state when receiving a limited timeline 2024-09-11 09:40:30 +02:00
Jorge Martín 08df153ed9 sdk-ui: create TimelineState::replace_all which combines clear and add_remote_events_at in the same transaction 2024-09-10 17:23:15 +02:00
Ivan Enderlin a6f84d8513 feat(sdk): Use the user ID to discover the sliding sync proxy.
This patch improves `Client::available_sliding_sync_versions` when
trying to detect the sliding sync proxy. Previously, we were relying
on the `Client::server` to send the `discover_homeserver::Request`.
Sadly, this value is an `Option<_>`, meaning it's not always defined
(it depends how the `Client` has been built with `HomeserverConfig`:
sometimes the homeserver URL is passed directly, so the server cannot
be known).

This patch tries to find to discover the homeserver by using
`Client::server` if it exists, like before, but it also tries by using
`Client::user_id`. Another problem arises then: the user ID indeed
contains a server name, but we don't know whether it's behind HTTPS or
HTTP. Thus, this patch tries both: it starts by testing with `https://`
and then fallbacks to `http://`.

A test has been added accordingly.
2024-09-10 14:09:50 +02:00
Benjamin Bouvier 729ba3e22b ffi: rename RustShieldState to SdkShieldState
This is all Rust code, after all :)
2024-09-10 11:20:52 +02:00
Doug 83cc0acf7b ffi: Expose RoomSendQueue::unwedge to allow resending. 2024-09-09 17:47:06 +02:00