Commit Graph

11480 Commits

Author SHA1 Message Date
Kevin Boos
c30ec0ed8a chore(sdk): Reduce log verbosity from info -> trace in a few functions (#4747)
At the default `INFO` log level, the log gets inundated with thousands
of emitted statements, primarily related to
`is_display_name_ambiguous()`. The execution of this tiny function
certainly doesn't need to be traced every time, at least not at the info
log level.

Note: some of these could be debatably reduced to debug level rather
than trace level, but I went with "trace" because they all seem to be
trace statements rather than actual debug dump outputs (there is no
actual program state dumped out).

Signed-off-by: Kevin Boos
[kevinaboos@gmail.com](mailto:kevinaboos@gmail.com)

---------

Signed-off-by: Kevin Boos <1139460+kevinaboos@users.noreply.github.com>
2025-03-31 15:11:06 +00:00
Ivan Enderlin
d6f2fd4304 test(base): Test BaseStateStore::load_rooms.
This patch adds tests for `BaseStateStore::load_rooms`. This patch also
updates the `test_derive_from_other` test.
2025-03-31 16:47:58 +02:00
Ivan Enderlin
cf5b8d3b33 test(base): Test StateStore::get_room_infos with the RoomLoadSettings arguments.
This patch tests the new behaviour of `StateStore::get_room_infos`.
2025-03-31 16:47:58 +02:00
Ivan Enderlin
2a67d7472a feat(base,sqlite,indexeddb): Use RoomLoadSettings to load all or one room.
This patch updates `BaseStateStore` and the `StateStore` trait along
with its implementors, to return all rooms or a single room from
`StateStore::get_room_infos`.

See the previous patch for more context.
2025-03-31 16:47:58 +02:00
Ivan Enderlin
9f74be26c3 feat(base): Introduce RoomLoadSettings.
This patch introduces the `RoomLoadSettings` enum. It is helpful to load
either all rooms or one room when activating a `BaseClient`, i.e. when a
session is initialized or restored.

It addresses a broader problem where, for large accounts with large
caches, creating a `BaseClient` takes many resources. In a resource
constrainted context, like a push notification process, it can eat all
resources up to the point the process is killed (then notifications can
be missed).

The idea is then to force the `BaseClient` to load a single room.

This patch installs the `RoomLoadSettings` argument everywhere it needs
to be. The next patch will use `RoomLoadSettings` to load either all
rooms or a single one.
2025-03-31 16:47:58 +02:00
Damir Jelić
fb04539418 refactor(encryption): Simplify the parsing of OAuthCrossSigningResetInfo
Now that OAuth isn't behind a feature flag a bunch of things can be
simplified.

Seems that we don't need a Client object either.
2025-03-31 13:06:28 +02:00
Richard van der Hoff
192cf0154a integration-test: Remove postgres container (#4858)
Followup on https://github.com/matrix-org/matrix-rust-sdk/pull/3983: now
that we don't have a sliding sync proxy, we don't need a postgres
container.
2025-03-28 16:51:12 +00:00
Damir Jelić
9acd649742 chore: Remove the RSA security advisory from our deny config
Since we don't depend on mas anymore, we don't depend on RSA either.

Let's remove the exception, lest we reintroduce the dependency and
security issue.
2025-03-28 17:08:42 +01:00
Ivan Enderlin
e8fcdf4360 doc(base): Update the description in the CHANGELOG.md. 2025-03-28 16:11:44 +01:00
Ivan Enderlin
43dbb6a021 refactor(base): Split BaseStateStore::set_or_reload_session into 3 distinct methods.
This patch splits `BaseStateStore::set_or_reload_session` into 3
distinct methods:

1. `set_session_meta` (hello again!),
2. `load_rooms`,
3. `load_sync_token`.

This patch also renames
`BaseStateStore::set_or_reload_session_from_other` into
`derive_from_other` to clarify its semantics. It calls these 3 methods
above as a combo.

Finally, this patch also updates `BaseClient::activate` to call these 3
methods above individually.
2025-03-28 16:11:44 +01:00
Ivan Enderlin
de615f2ffe refactor(base): Rename BaseClient::set_or_reload_session and ::logged_in.
This patch renames `BaseClient::set_or_reload_session`
to `BaseClient::activate`, and `BaseClient::logged_in` to
`BaseClient::is_activated`.

The idea behind these renamings is to introduce a “state” for the
`BaseClient`: it is activated when is has a `SessionMeta`, has loaded
its data from the storages, and has an `OlmMachine`. Consequently, the
`logged_in` method is renamed `is_activated` for the symmetry. If one
wants to know if the client is logged in, it can use `is_activated`, or
also `MatrixAuth::logged_in`.
2025-03-28 16:11:44 +01:00
Ivan Enderlin
f11eec4caf doc(base): Update CHANGELOG.md. 2025-03-28 16:11:44 +01:00
Ivan Enderlin
f445a5ca57 test(base): Add tests for Store::set_or_reload_session*.
This patch adds tests for the `set_or_reload_session` and
`set_or_reload_session_from_other` methods.
2025-03-28 16:11:44 +01:00
Ivan Enderlin
68605de596 feat(base): Add Store::set_or_reload_session_from_other.
This patch adds the `Store::set_or_reload_session_from_other` method to
isolate the behaviour of deriving a store from another one.
2025-03-28 16:11:44 +01:00
Ivan Enderlin
db97d616f6 refactor(base): Rename set_session_meta to set_or_reload_session.
This patch renames the various `set_session_meta` methods to
`set_or_reload_session`. The idea is to highlight that the method is not
a simple setter: it sets but it _also_ updates the store' state.

The private shortcut method in `matrix_sdk::Client::set_session_meta`
is removed, and caller uses `client.base_client().set_or_reload_session`
instead. Why removing this `Client::set_session_meta` shortcut
method? Because it was creating confusion with another method:
`Client::restoring_session`. This private shortcut method wasn't used in
a lot of places, then I believe it's a nice improvement.
2025-03-28 16:11:44 +01:00
Damir Jelić
e2e5b39afa test(sdk): Test that resetting cross-signing with an invalid password errors out 2025-03-28 15:23:52 +01:00
Damir Jelić
6fec953ff0 test(sdk): Use the MatrixMockServer for the cross-signing reset test 2025-03-28 15:23:52 +01:00
Damir Jelić
95befc9a25 fix(encryption): Return the uiaa error if we have one in the identity reset loop 2025-03-28 15:23:52 +01:00
Stefan Ceriu
cb92971657 chore(ui): move TimelineItemContent::UnableToDecrypt to MsgLikeKind::UnableToDecrypt 2025-03-28 15:30:47 +02:00
Stefan Ceriu
5a35fec894 chore(ui): rename RedactedMessage to just Redacted 2025-03-28 15:30:47 +02:00
Stefan Ceriu
43b8f83e4b chore(ui): move TimelineItemContent::RedactedMessage to MsgLikeKind::RedactedMessage 2025-03-28 15:30:47 +02:00
Stefan Ceriu
0952255a50 chore(ui): reoder MsgLike helpers so that as_foo and is_foo are grouped 2025-03-28 15:30:47 +02:00
Ivan Enderlin
8738c4dbfd test(sqlite): Add test for cache_size and journal_size_limit.
This patch adds tests for checking the `PRAGMA cache_size` and `PRAGMA
journal_size_limit`.
2025-03-28 13:36:32 +01:00
Ivan Enderlin
99436f8e79 test(sqlite): Test the new RuntimeConfig type. 2025-03-28 13:36:32 +01:00
Ivan Enderlin
339b220488 feat(sqlite): Introduce RuntimeConfig which includes cache_size
This patch updates `StoreOpenConfig` to hold a new type: `RuntimeConfig`.

This `RuntimeConfig` type is passed to a new `SqliteAsyncConnExt`
method, named `apply_runtime_config`. Depending on the values passed
here, the `optimize`, `cache_size` (new!) and `journal_size_limit`
methods will be called automatically.

The goal of this type is to automate a flow we keep repeating in
all the stores. This is error-prone. This type brings uniformity and
consistency.

This patch also makes all `open_with_pool` methods on the stores private
(they were public before):

1. they were never used as far as I know because getting a `SqlitePool`
   isn't possible since the `pool` attribute is private…
2. it's better to keep control of this flow.
2025-03-28 13:36:32 +01:00
Ivan Enderlin
661f381e34 chore: Run rustfmt with an older nightly version. 2025-03-28 10:54:48 +01:00
Ivan Enderlin
8d4ccf6442 doc(sdk,base): Update CHANGELOG.mds. 2025-03-28 10:54:48 +01:00
Ivan Enderlin
bd6b7c2ce1 refactor(base): Rename BaseClient::store to state_store.
This patch renames `BaseClient::store` to `state_store`, and
inevitably `Client::store` to `state_store` too.
2025-03-28 10:54:48 +01:00
Ivan Enderlin
9152d84b06 refactor(base): Rename BaseClient::store to state_store.
This patch pursues the same goal as the previous one: `Store` has
been renamed `BaseStateStore`, so the `store` field holding this
`BaseStateStore` is renamed `state_store`.
2025-03-28 10:54:48 +01:00
Ivan Enderlin
c044f81d7b refactor(base): Rename Store to BaseStateStore.
This patch renames `Store` to `BaseStateStore`. Ideally, I would
like to rename to `StateStore` but that's already a trait name
(`traits::StateStore`).

Why this renaming? To clarify what store it is.
2025-03-28 10:54:48 +01:00
Stefan Ceriu
5730f0e00e chore(ui): introduce an as_message MsgLikeContent helper and use in tests 2025-03-27 15:53:31 +02:00
Stefan Ceriu
76f92ba9af chore(ui): rename AggregatedTimelineItemContent to MsgLikeContent and AggregatedTimelineItemContentKind to MsgLikeKind.
- we decided on this naming convention to keep consistent with Ruma which uses `MsgLike` as well
2025-03-27 15:53:31 +02:00
Stefan Ceriu
d599c72278 chore(ui): use a newer version of as_variant to match nested types. 2025-03-27 15:53:31 +02:00
Stefan Ceriu
e5243e32be chore(ui): simplify the fetch_replied_to_event method 2025-03-27 15:53:31 +02:00
Stefan Ceriu
db18e7fd74 chore(ui): simplify the test by using more of the TimelineItemContent helpers 2025-03-27 15:53:31 +02:00
Johannes Marbach
f3baf7efd2 refactor(timeline): push the reply logic down into matrix_sdk (#4842)
This achieves step 2 of #4835.

Signed-off-by: Johannes Marbach <n0-0ne+github@mailbox.org>
2025-03-27 13:47:51 +01:00
Benjamin Bouvier
f6e223edf6 refactor(timeline): bump as_variant and make more use of its pattern matching form 2025-03-27 10:42:22 +01:00
Stefan Ceriu
4f3b40d6fb feat!(timeline): Introduce an extra TimelineItemContent layer that holds aggregations (#4839)
In preparation for threads we have realised that the `reactions`,
`thread_root` and `in_reply_to` were only available on `Message` types,
which doesn't play well with Stickers and Polls.

This PR introduces a new `Aggregated` `TimelineItemContent` variant
which holds the message `kind` (Message, Sticker, Poll) as well as well
as any related aggregated data. it will help treat them all in a similar
fashion as well as account for future changes.

There are no functional changes, it's mostly about moving code around
and the FFI interfaces haven't changed.

Part of #4833.
2025-03-26 16:27:03 +00:00
Richard van der Hoff
6e480271d3 crypto: get_most_recent_session: return None for unknown device (#4846)
If we have a device whose Curve25519 key we don't know, then
self-evidently we can't have any active Olm sessions with that device.
Currently, we return an `EventError::MissingSenderKey` in this case, but
(a) the definition of that error doesn't match this situation, and (b)
it complicates handling in methods that call `DeviceData::encrypt`
(currently only `DeviceData::maybe_encrypt_room_key`, but I want to add
a second).

Other than `DeviceData::encrypt`, the only place where
`get_most_recent_session` is called is `mark_device_as_wedged`. In that
case, we have just looked up the device by its Curve25519 key, so we
know it must have one.

We can therefore be reasonably certain that this change is a no-op.
2025-03-26 14:42:24 +00:00
Ivan Enderlin
e60cf18337 refactor(base): Rename BaseClient::with_store_config to new.
This renames the `BaseClient::with_store_config` constructor to `new`:

1. there is no alternative constructor, it's the only one,
2. the `with_` prefix is usually reserved to (i) builders or (ii)
   alternative constructors,
3. I believe it clarifies the code.
2025-03-26 15:34:08 +01:00
Ivan Enderlin
6409adb879 doc(base): Remove an empty line in an example. 2025-03-26 15:34:08 +01:00
Ivan Enderlin
915e0e83bc doc(base): Fix documentation of BaseClient::with_store_config.
The documentation is outdated, `config` is now a `StoreConfig`.
2025-03-26 15:34:08 +01:00
Ivan Enderlin
8323ecdc8b doc(base): Improve documentation of BaseClient.
This patch:

* fixes the mention of “no IO”, it lacks the “network” part,
* adds an example of how to build a `BaseClient`,
* mentions that it is better be used via `matrix_sdk`.
2025-03-26 15:34:08 +01:00
Kévin Commaille
e0e9c06ca4 Don't use serde to avoid returning an error
Signed-off-by: Kévin Commaille <zecakeh@tedomum.fr>
2025-03-26 15:26:55 +01:00
Kévin Commaille
eb313efdeb Don't qualify error! macro
It's already imported.

Signed-off-by: Kévin Commaille <zecakeh@tedomum.fr>
2025-03-26 15:26:55 +01:00
Kévin Commaille
bc22ff1221 refactor(oauth): Introduce AccountManagementUrlBuilder
It allows to reuse the URL for different actions more easily than having
to call `OAuth::account_management_url` every time for a different
action.

It also adds a method with fallback if we want to ignore action
serialization errors, to always present a URL.

Signed-off-by: Kévin Commaille <zecakeh@tedomum.fr>
2025-03-26 15:26:55 +01:00
Benjamin Bouvier
8c988beaf2 doc(linked chunk): tweak comments related to clearing/dropping a linked chunk 2025-03-26 11:57:48 +01:00
Benjamin Bouvier
752c9baf7c refactor(timeline): simplify removal of duplicated local echo item 2025-03-26 11:33:20 +01:00
Benjamin Bouvier
766772f654 feat(timeline): insert the start of the timeline in places where it's required 2025-03-26 11:33:20 +01:00
Benjamin Bouvier
f5b6767253 feat(timeline): add a timeline start virtual item 2025-03-26 11:33:20 +01:00