Commit Graph

11252 Commits

Author SHA1 Message Date
Kévin Commaille
bc92e55b53 Improve tests
Signed-off-by: Kévin Commaille <zecakeh@tedomum.fr>
2025-03-07 13:10:52 +01:00
Kévin Commaille
230feff430 test(sdk): Add tests for handle_refresh_tokens and Oidc
Signed-off-by: Kévin Commaille <zecakeh@tedomum.fr>
2025-03-07 13:10:52 +01:00
Kévin Commaille
8bb4387dc4 fix(oidc): Match the proper error type for invalid refresh token
Since we do not use mas-oidc-client anymore, the error to match has changed.

Signed-off-by: Kévin Commaille <zecakeh@tedomum.fr>
2025-03-07 13:10:52 +01:00
Kévin Commaille
2506ba8364 refactor(oidc): Use oauth2 for token revocation
Signed-off-by: Kévin Commaille <zecakeh@tedomum.fr>
2025-03-07 12:50:58 +01:00
Damir Jelić
daad6d662f fix(multiverse): Don't wait for sync service state changes when shutting down
The SyncService::stop method guarantees that the sync service will be
stopped after it has completed so there's no need to wait for state
changes.

The state change might not even come, if you pressed `S` to stop the
sync service manually.
2025-03-06 16:16:11 +01:00
Damir Jelić
53853c2d9a refactor(multiverse): Put the login logic into a separate function 2025-03-06 15:46:07 +01:00
Damir Jelić
40de714e81 refactor(multiverse): Use clap to simplify the CLI argument parsing 2025-03-06 15:46:07 +01:00
Damir Jelić
27bde16843 refactor(multiverse): Simplify the terminal and panic hook setups 2025-03-06 15:46:07 +01:00
Damir Jelić
5e8f8d5513 refactor(multiverse): Simplify the tracing setup 2025-03-06 15:46:07 +01:00
Damir Jelić
120970c4ea chore(multiverse): Bump the deps 2025-03-06 15:46:07 +01:00
Kévin Commaille
740e729606 docs(oidc): Document the arguments of url_for_oidc
Signed-off-by: Kévin Commaille <zecakeh@tedomum.fr>
2025-03-06 12:27:30 +01:00
Kévin Commaille
60b140b684 chore: Add changelog for using oauth2
Signed-off-by: Kévin Commaille <zecakeh@tedomum.fr>
2025-03-06 12:27:30 +01:00
Kévin Commaille
9a165468eb test(oidc): Add more checks for the authorization URL
Signed-off-by: Kévin Commaille <zecakeh@tedomum.fr>
2025-03-06 12:27:30 +01:00
Kévin Commaille
e15897b3f1 refactor(oidc): Use oauth2 for authorization code grant
Signed-off-by: Kévin Commaille <zecakeh@tedomum.fr>
2025-03-06 12:27:30 +01:00
Kévin Commaille
52f98582f1 refactor(oidc): Use oauth2 client for refreshing access tokens
Signed-off-by: Kévin Commaille <zecakeh@tedomum.fr>
2025-03-06 12:27:30 +01:00
Kévin Commaille
2e72c23868 refactor(oidc): Move error types to the error module
Signed-off-by: Kévin Commaille <zecakeh@tedomum.fr>
2025-03-06 12:27:30 +01:00
Kévin Commaille
0967027feb refactor(oidc): Use ClientId type from oauth2
Avoids to use 2 similar types with the same name.

Signed-off-by: Kévin Commaille <zecakeh@tedomum.fr>
2025-03-06 12:27:30 +01:00
Andy Balaam
6c9b1ef3c1 fix(common): Rename all snapshots in deserialized_responses to have shorter names matrix-sdk-ffi/20250306 2025-03-05 15:29:44 +00:00
Damir Jelić
8cceded0ae refactor(oidc): Move the fallback issuer discovery logic into a separate method 2025-03-05 15:37:04 +01:00
Jorge Martín
ff181475a0 fix(client): Add handle_verification_events field to BaseClient.
This is done to fix an issue with these events being received and processed twice when `NotificationProcessSetup` is `SingleProcess`, causing issues with user verification.

This can be used to ignore verification requests in this sliding sync instance, preventing issues found where several sliding sync instances with the same client process events simultaneously and re-process the same verification request events during their initial syncs.
2025-03-05 15:09:31 +01:00
Andy Balaam
074c0e59e0 fix(common): Shorten the name of the snapshot_test_encryption_info 2025-03-05 14:03:51 +00:00
Kévin Commaille
1d7c60c46a chore: Add changelog about ID tokens support removal
Signed-off-by: Kévin Commaille <zecakeh@tedomum.fr>
2025-03-05 14:19:27 +01:00
Kévin Commaille
377f34fae2 refactor(oidc): Get rid of OidcBackend
Now that we don't use it for tests, we don't need it anymore.

Signed-off-by: Kévin Commaille <zecakeh@tedomum.fr>
2025-03-05 14:19:27 +01:00
Kévin Commaille
26cb805e0f test(oidc): Use MatrixMockServer in the remaining tests
Gets rid of the MockImpl for OidcBackend.

Signed-off-by: Kévin Commaille <zecakeh@tedomum.fr>
2025-03-05 14:19:27 +01:00
Kévin Commaille
81dbe2060c refactor(oidc): Remove support for ID tokens
ID tokens are a feature of OpenID Connect, we don't need them to support OAuth 2.0.

Signed-off-by: Kévin Commaille <zecakeh@tedomum.fr>
2025-03-05 14:19:27 +01:00
Ivan Enderlin
fd0fca436b chore(sdk): Remove the request_body instrument's field.
Many fields here are not argument of the `send` method, but are set
later with `Span::record`. Grepping all these fields reveal they are all
set except `request_body` apparently.
2025-03-05 14:15:29 +01:00
Ivan Enderlin
3d653d3fdc fix(sqlite): Design a new schema to get faster insertions.
This patch is twofold. First off, it provides a new schema allowing to
improve the performance of `SqliteEventCacheStore` for 100_000 events
from 6.7k events/sec to 284k events/sec on my machine.

Second, it now assumes that `EventCacheStore` does NOT store invalid
events. It was already the case, but the SQLite schema was not rejecting
invalid event in case some were handled. It's now explicitely forbidden.
2025-03-05 13:57:08 +01:00
Ivan Enderlin
b22bb3ee9f fix(sqlite): Use a prepared statement to insert events.
This patch uses a prepared statement to insert events in the linked
chunks. It offers more predictable performance, and SQLite prefers that.
2025-03-05 13:57:08 +01:00
Ivan Enderlin
7f17b4be7b bench: Add a benchmark for the LinkedChunk with the EventCacheStore. 2025-03-05 13:57:08 +01:00
Benjamin Bouvier
fa3a9d81e3 refactor(event cache): use Ruma's is_redacted() method instead of original_content()
This is cheaper, as it doesn't require cloning the content and
immediately throw it away. This method was introduced recently, thanks
to Kevin for it.
2025-03-05 12:14:04 +01:00
Ivan Enderlin
892c99f0f3 test(sqlite): Improve a test to check uniqueness constraint. 2025-03-05 12:02:30 +01:00
Ivan Enderlin
8d8846a259 chore(sdk): Remove EventsPostProcessing.
This patch removes the `EventsPostProcessing` type, it assumes
`with_events_muts` will always return events that will be post-process.
The case where `EventsPostProcessing::None` becomes a `vec![]`.
2025-03-05 11:30:55 +01:00
Ivan Enderlin
9d63af6271 chore(sdk): maybe_apply_new_redaction no longer takes a &RoomVersionId.
This patch updates `maybe_apply_new_redaction` to remove the first
`&RoomVersionId` argument. Indeed, due to the refactoring, it's now
possible for `maybe_apply_new_redaction` to read this value directly
from `Self::room_version`.
2025-03-05 11:30:55 +01:00
Ivan Enderlin
37ad82adfc doc(sdk): Add missing documentation. 2025-03-05 11:30:55 +01:00
Ivan Enderlin
57953b9ae9 chore(sdk): Make Clippy happy. 2025-03-05 11:30:55 +01:00
Ivan Enderlin
777fb920f6 fix(sdk): maybe_apply_new_redaction updates in-store events.
This patch updates `maybe_apply_new_redaction` so that it is able to
update/redact an event found in the store.
2025-03-05 11:30:55 +01:00
Ivan Enderlin
05750e871b task(sdk): maybe_apply_new_redaction uses find_event.
This patch updates `maybe_apply_new_redaction` to use `find_event`, so
that the target event is looked up in memory or in the store.

The case where it is in the store is a simple `todo!()` for the moment.
I wanted to separate the update of the `maybe_apply_new_redaction`
signature from the `InStore` implementation. The method is now async and
returns a `Result`.
2025-03-05 11:30:55 +01:00
Ivan Enderlin
5a11b8b836 task(sdk): RoomEventCacheState::find_event returns the event location.
This patch introduces `EventLocation` to know if an event has been found
in the memory (in `RoomEvents`) or in the store (in `EventCacheStore`).

This is used by the `RoomEventCacheState::find_event`.
2025-03-05 11:30:55 +01:00
Ivan Enderlin
8a785ea855 task(sdk): Move maybe_apply_new_redaction from RoomEvents inside RoomEventCacheState.
This patch moves the `maybe_apply_new_redaction` method from
`RoomEvents` inside `RoomEventCacheState` so that it has an access
to the store (necessary for the next patch). This patch creates a new
`RoomEvents::replace_event_at` method, which is a thin wrapper around
`LinkedChunk::replace_item_at`.
2025-03-05 11:30:55 +01:00
Ivan Enderlin
1874a76f67 task(sdk): Rename a variable, and AllEventsCache only stores valid events.
This patch renames `sync_timeline_events` into `timeline_events`.
Moreover, this change has spotted a possible improvement
in `AllEventsCache` where it now receives events from
`collect_valid_and_duplicated_events`, which allows to only store valid
events in it.
2025-03-05 11:30:55 +01:00
Ivan Enderlin
0b2b528962 task(sdk): Callback in with_events_mut returns an EventsPostProcessing.
This patch updates the callback passed to `with_events_mut`. It now
returns an `EventsPostProcessing` which can automatically run the, now
inlined, `on_new_events`.

This patch updates where the `RoomVersionId` is also stored. It's not
held by `RoomEventCacheState` instead of `RoomEventCacheInner`.
2025-03-05 11:30:55 +01:00
Ivan Enderlin
2036c3da9d doc(sdk): Fix documentation of with_events_mut. 2025-03-05 11:30:55 +01:00
Benjamin Bouvier
7694b016da chore: disable LTO on release builds
I have to disable LTO every time I'm building any final binary using the
SDK, because otherwise, the builds can take easily more than 10 minutes
to complete, killing iteration times, and making it almost impractical
to use the programs (benchmarks, or multiverse).

I think it should be the decision of the final embedder to enable or
disable LTO, and that for the purpose of our own binaries hosted in the
SDK repository, we don't need the absolute best performance (or, for the
sake of benchmarking, we can tweak the profiling profile).
2025-03-05 10:55:15 +01:00
Benjamin Bouvier
6fdd59157a fix(timeline): steal hiddden receipts from the previous item, when inserting in the middle 2025-03-05 09:42:14 +01:00
Benjamin Bouvier
0d7096fa94 test(timeline): add regression test for duplicate read receipts 2025-03-05 09:42:14 +01:00
Benjamin Bouvier
a94dc4e89b chore(timeline): add more logs for read receipts 2025-03-05 09:42:14 +01:00
Benjamin Bouvier
bf965b2a17 feat(timeline): add an invariant check that there's no duplicate read receipts 2025-03-05 09:42:14 +01:00
Benjamin Bouvier
9c87625910 chore(event cache): include the room id in the sending linked chunk updates to the store log 2025-03-05 08:56:37 +01:00
Benjamin Bouvier
3f1543504a test(timeline): add an equivalent test when storage's enabled 2025-03-05 08:56:37 +01:00
Benjamin Bouvier
3773968d19 fix(timeline): remove events when back-paginating too
The previous strategy was incorrect, see the new doc comment explaining
why with the example taken from the regression test.
2025-03-05 08:56:37 +01:00