Commit Graph

11715 Commits

Author SHA1 Message Date
Ivan Enderlin
9adb0deaa5 refactor(base): room::msc4186::update_any_room uses room::Room.
This patch uses the `room::Room` structure in
`room::msc4186::update_any_room` to reduce its number of arguments. It
results in the removal of te `allow(clippy::too_many_arguments)`.
2025-04-15 14:17:07 +02:00
Ivan Enderlin
61b711ce76 chore(base): Create the room::Room structure.
This patch creates the `room::Room` structure to group common arguments
in the `room` processors.
2025-04-15 14:17:07 +02:00
Ivan Enderlin
9e6dc71609 refactor(base): Remove the BaseStateStore argument in room:sync_v2::* processors.
This patch removes the `BaseStateStore` argument in `room::sync_v2::*`
response processors as it can be fetched from the `Notification`
argument.
2025-04-15 14:17:07 +02:00
Ivan Enderlin
33b1c02873 chore(base): Rename room_data to room_response.
This patch tries to clarify that the `room_data` _is_ the HTTP response.
2025-04-15 14:17:07 +02:00
Ivan Enderlin
f4ad575090 refactor(base): Remove SessionMeta from update_any_room.
This patch removes the `SessionMeta` argument of
`room::msc4186::update_any_room`. Tracking its usage, it reveals that
providing a `UserId` is sufficient. Happily, we already provide a
`UserId`, hence making `SessionMeta` useless here.
2025-04-15 14:17:07 +02:00
Ivan Enderlin
f55730716a chore(base): Rename a variable room_type to room_state. 2025-04-15 14:17:07 +02:00
Ivan Enderlin
bad1c683f8 chore(base): Rename fields of RoomUpdate.
This patch renames the fields in `RoomUpdate`: `join` becomes `joined`,
`leave` becomes `left`, `invite` becomes `invited`, to match their
associate type.
2025-04-15 14:17:07 +02:00
Ivan Enderlin
2479339c46 refactor(base): Simplify the flow of membership.
This patch simplifies the flow of `membership` when the room is an
invited room.

Previously, we were creating the room as `Invited`. Then, later
overriding it to `Knocked` if we found it was such a room. Otherwise, we
were overriding it again to `Invited`. Well. Now the flow is simpler.
2025-04-15 14:17:07 +02:00
Ivan Enderlin
45d5d1a802 refactor(base): Remove the numerous Option<…> returned by update_any_room.
This patch removes the 4 `Option<…>` returned by `update_any_room`: they
are replaced by a single new `RoomUpdateKind` enum.
2025-04-15 14:17:07 +02:00
Ivan Enderlin
a218105aca refactor(base): Create the room::msc4186::update_any_room response processor.
This patch extracts the `BaseClient::process_sliding_sync_room` method
into the new `msc4186::update_any_room` response processor. So far, this
is purely a code move, without any changes (modulo method-to-function
transformation).

With `BaseClient:process_sliding_sync_room` comes
`BaseClient::process_sliding_sync_room_membership`,
`BaseClient::handle_own_room_membership`, `process_room_properties` and
`cache_latest_events`.
2025-04-15 14:17:07 +02:00
Ivan Enderlin
6bbb7fb498 chore(base): Remove unnecessary comments.
This patch removes comments that are irrelevant today. There is nothing
to fix.
2025-04-15 14:17:07 +02:00
Ivan Enderlin
f32d0099fc chore(base): Make Clippy happy. 2025-04-15 11:57:39 +02:00
Ivan Enderlin
6d9cf861f6 chore(base): Remove the re-exports in timeline::builder.
This patch removes the re-exports of `Notification` and `E2EE` in
`timeline::builder`. Let's make things simple now that they are used
outside the `timeline` processors.
2025-04-15 11:57:39 +02:00
Ivan Enderlin
13e565a4dc refactor(base): Create the room::sync_v2::update_knocked_room response processor.
This patch creates the `update_knocked_room` processor, extracted from
the sync v2 flow.
2025-04-15 11:57:39 +02:00
Ivan Enderlin
aeca1f1495 refactor(base): Use Notification wherever possible.
This patch groups arguments behind the `Notification` struct
if it makes sense. This patch also uses the new method
`Notification::push_notification_from_event_if` method to replace
duplicated code.
2025-04-15 11:57:39 +02:00
Ivan Enderlin
c16bc6b435 refactor(base): Move and improve the Notification struct in response processors.
This patch moves the `timeline::builder::Notification` into
its own module, `notification`. This patch adds two methods:
`push_notification` and `push_notification_from_event_if`.
2025-04-15 11:57:39 +02:00
Ivan Enderlin
846fcfb408 feat(base): Add From implementations to build a RawAnySyncOrStrippedTimelineEvent.
This patch adds two `From` implementations on
`RawAnySyncOrStrippedTimelineEvent` to create the correct variant of
this enum. This is useful when we get generic types and want to build
this type.
2025-04-15 11:57:39 +02:00
Ivan Enderlin
1141b7db1a refactor(base): Create the room::sync_v2::update_invited_room response processor.
This patch creates the `update_invited_room` processor by extracting the
code for the sync v2 flow.
2025-04-15 11:57:39 +02:00
Ivan Enderlin
b85a1a0998 refactor(base): Create the room::sync_v2::update_left_room response processor.
This patch creates the `update_left_room` processor, extracted from the
sync v2 flow.

I've noticed that `new_user_ids` is not used, so it has been put behind
a `_` variable for the moment, but some computations have been removed.
We need to clean this user ID flow.
2025-04-15 11:57:39 +02:00
Ivan Enderlin
e62313d7ba reefactor(base): Create the room::sync_v2::update_joined_room response processor.
This patch extracts the logic to handle a `JoinedRoom` in a response
processor.
2025-04-15 11:57:39 +02:00
Ivan Enderlin
71510de602 refactor(base): Extract timeline::builder::E2EE into e2ee, and use it more.
This patch moves the `timeline::builder::E2EE` type into the `e2ee`
module. Gathering these 3 E2EE values in the same type was a good idea,
and is now applied to more places in the response processors.
2025-04-15 11:57:39 +02:00
Ivan Enderlin
28888a414b refactor(base): Compute now if and only if Level::INFO is enabled.
This patch computes the `now` variable if and only if it is required.
It is used by an `info!` log, so let's condition the creation of `now`
to that.
2025-04-15 11:57:39 +02:00
Ivan Enderlin
3538bb91e3 refactor(base): Context derives Default.
This patch makes `Context` to derive `Default`. The `new` constructor
also no longer takes a `RoomInfoNotableUpdates`, since it was always
used with a default value, it generates this value by itself.
2025-04-15 11:57:39 +02:00
Ivan Enderlin
fdcc6dbeda chore(base): Replace an unwrap by an expect.
This patch updates a comment and replaces an `unwrap` by an `expect`.
2025-04-15 11:57:39 +02:00
dependabot[bot]
f1cd8120a8 chore(deps): Bump tj-actions/changed-files
Bumps [tj-actions/changed-files](https://github.com/tj-actions/changed-files) from 6f67ee9ac810f0192ea7b3d2086406f97847bcf9 to 9b4bb2bedb217d3ede225b6b07ebde713177cd8f.
- [Release notes](https://github.com/tj-actions/changed-files/releases)
- [Changelog](https://github.com/tj-actions/changed-files/blob/main/HISTORY.md)
- [Commits](6f67ee9ac8...9b4bb2bedb)

---
updated-dependencies:
- dependency-name: tj-actions/changed-files
  dependency-version: 9b4bb2bedb217d3ede225b6b07ebde713177cd8f
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>
2025-04-15 11:31:54 +02:00
Richard van der Hoff
473852c7d5 Merge pull request #4922 from matrix-org/rav/check_sender_device_keys
crypto: check `sender_device_keys` on incoming Olm messages
2025-04-15 10:18:50 +01:00
Ivan Enderlin
f19f8b25db fix(sdk): Remove include_heroes in sliding sync requests.
This patch removes all mentions of `include_heroes`. This field isn't
part of the MSC4186. We have the `test_compute_heroes_from_sliding_sync`
which continues to pass, everything fine on that side. There is no
mention of `include_heroes` in Synapse at the time of writing. It seems
to be an artifact from the sliding sync proxy experiment.
2025-04-14 18:26:27 +02:00
Jonas Richard Richter
4de202fc64 doc(changelog): add entry for room topic string in StateEventContent 2025-04-14 15:43:17 +02:00
Jonas Richard Richter
7b206d33f0 feat(ffi): update RoomTopic AnySyncStateEvent variant to include topic string 2025-04-14 15:43:17 +02:00
Ivan Enderlin
085de8bdae refactor(base): Create the ephemeral_events response processor.
This patch creates the `ephemeral_events` response processors:
`dispatch` and `dispatch_one`.

This remove duplicated code.
2025-04-14 08:48:18 +02:00
Ivan Enderlin
fe0b954019 refactor(base): Create the dispatch_invite_and_knock response processor.
This patch creates the
`state_events::stripped::dispatch_invite_and_knock`, that is migrated
from the `BaseClient::handle_invite_state` method.
2025-04-14 08:48:18 +02:00
Ivan Enderlin
e21ae2ae53 chore(base): Move dispatch_and_get_new_users inside the sync module.
This patch moves the `state_events::dispatch_and_get_new_users`
processor inside the `state_events::sync` module. Why? Because a similar
processor for `state_events::stripped` is about to be created.
2025-04-14 08:48:18 +02:00
Jorge Martín
0306683cbf feat(ffi): Add extra details to ClientError.
Also split `ClientError::new` into `ClientError::from_str` and `ClientError::from_err` so we can automatically get the details from the 2nd one.
2025-04-11 15:49:20 +02:00
Richard van der Hoff
e020ba1023 crypto: check sender_device_keys on incoming Olm messages
MSC4147 added a `sender_device_keys` property to olm-encrypted to-device
messages, with recommendations about checking the values in that propety. We do
(most of?) those checks for `m.room_key` messages today, but not other types of
to-device message.
2025-04-11 12:00:18 +01:00
Richard van der Hoff
0697e0705b crypto: support MSC4147 device keys on custom to-device events
MSC4147 added a `sender_device_keys` property to the plaintext of *all*
olm-encrypted events. 03d4a30eb added the field to `DecryptedOlmV1Event`, but
due to Reasons, there is an almost-parallel struct `ToDeviceCustomEvent` which
is used for event types other than the 4 we have content types for.

To complete the set, let's add the field to `ToDeviceCustomEvent`.
2025-04-11 11:01:22 +01:00
Ivan Enderlin
1e938df90d Merge pull request #4921 from Hywan/release-0.11.0
chore: Release matrix-sdk version 0.11.0
matrix-sdk-crypto-ffi-0.11.0 matrix-sdk-indexeddb-0.11.0 matrix-sdk-0.11.0 matrix-sdk-ui-0.11.0 matrix-sdk-sqlite-0.11.0 matrix-sdk-ffi-0.11.0 matrix-sdk-test-macros-0.11.0 matrix-sdk-qrcode-0.11.0 matrix-sdk-crypto-0.11.0 matrix-sdk-store-encryption-0.11.0 matrix-sdk-test-0.11.0 matrix-sdk-base-0.11.0 matrix-sdk-common-0.11.0
2025-04-11 11:06:43 +02:00
Ivan Enderlin
5d55bb4955 chore: Release matrix-sdk version 0.11.0 2025-04-11 10:51:30 +02:00
Ivan Enderlin
8abd9fb303 doc(releasing): Fixing markdown.
Remove unbreakable spaces, and add indentations.
2025-04-11 10:42:37 +02:00
Ivan Enderlin
d5ee644443 refactor(base): Reorganize the state_events processors.
This patch tries to clarify the processors in `state_events` by
putting them in two modules: `sync` and `stripped`, along with a bit
of renaming:

- `collect_sync` becomes `sync::collect`,
- `collect_sync_from_timeline` becomes `sync::collect_from_timeline`,
- `collect_stripped` becomes `stripped::collect`.

I believe this is an improvement.
2025-04-11 10:32:08 +02:00
Ivan Enderlin
06022aa23a chore(base): Remove a _ in front of a variable.
This ptach removes a `_` in front of a variable: it is used, if and only
if the `e2e-encryption` feature is enabled. Make it stand out.
2025-04-11 10:32:08 +02:00
Ivan Enderlin
8ea0d9542d chore(base): Rename process_if_candidate to process_if_relevant. 2025-04-11 10:32:08 +02:00
Ivan Enderlin
63938bf2c7 chore(base): Remove an unnecessary allow(clippy…). 2025-04-11 10:32:08 +02:00
Ivan Enderlin
acff6c2e1d doc(base): Fix an intra-link in the documentation. 2025-04-11 10:32:08 +02:00
Ivan Enderlin
1013843071 refactor(base): Create the timeline::build response processor.
This patch does the following things:

1. moves the `BaseClient::handle_timeline` method as the
   `timeline::build` response processor.
2. moves the `BaseClient::update_push_room_context` method as a private
   function of the `timeline` response processor module,
3. moves the `BaseClient::get_push_room_context` method as a public
   function of the `timeline` response processor module.

The scope of the `timeline::build` processor is a bit too broad, but at
least the number of methods on `BaseClient` are greatly reduced.
2025-04-11 10:32:08 +02:00
Ivan Enderlin
a0bfd3e21e chore(clippy): Make Clippy happy. 2025-04-11 10:32:08 +02:00
Ivan Enderlin
68352e8339 chore(base): Rename variables for the sake of clarity.
Don't know what `event`, `e`, `e`, `e` or `r` represent? Me neither.
This patch tries to fix that.
2025-04-11 10:32:08 +02:00
Ivan Enderlin
6a5e24a64a refactor(base): Create the verification::process_if_candidate response processor.
This patch creates a new `verification::process_if_candidate` response
process. The idea is the check whether a `AnySyncTimelineEvent` suits to
be a verification event that must be processed.

This piece of code was repeated in three different places in the code.
Now it's unique.
2025-04-11 10:32:08 +02:00
Ivan Enderlin
db6d1b4cd6 refactor(base): BaseClient::handle_timeline no longer handle state events.
This patch removes the `ignore_state_events` argument from
`BaseClient::handle_timeline`. This method no longer handles state
events. Consequently, the `user_ids` and `ambiguity_cache` arguments are
also removed.

This patch updates the flow to use the new
`state_events::collect_sync_from_timeline` processor, and to re-use the
`state_events::dispatch_and_get_new_users` processor.

The positive impact of this patch is that it re-uses existing code
(hurray). However, the downside is that state events are deserialized
twice for the moment.
2025-04-11 10:32:08 +02:00
Ivan Enderlin
b0c1eda682 refactor(base): Create the state_events::dispatch_and_get_new_users response processor.
This patch extracts the `BaseClient::handle_state` method as a new
response processor named `state_events::dispatch_and_get_new_users`.
It appears that we can do something more elegant with the returned new
users. See the next patch.
2025-04-11 10:32:08 +02:00
Ivan Enderlin
afecd6d508 chore(base): Simplify code by calling iter::zip instead of Iterator::zip.
This patch uses `iter::zip` to replace `Iterator::zip`. It does exactly
the same, it's just shorter.
2025-04-11 10:32:08 +02:00