Commit Graph

12126 Commits

Author SHA1 Message Date
Damir Jelić
41a5fd90f4 feat(tests): Add a macro to assert that a TimelineEventKind was encrypted 2025-05-27 17:46:10 +02:00
Damir Jelić
3d9d619f8b feat(sdk): Import the room keys we download from the shared history bundle 2025-05-27 17:46:10 +02:00
Damir Jelić
af38f0d1ee refactor(crypto): Move the room key bundle import method under the store 2025-05-27 17:46:10 +02:00
Damir Jelić
091a5fb354 refactor(crypto): Clarify some things in the room key bundle import logic 2025-05-27 17:46:10 +02:00
Richard van der Hoff
8a1d6ce0eb feat(sdk): Attempt to download room key bundles when we accept an invite 2025-05-27 17:46:10 +02:00
Ivan Enderlin
0f5f24527b chore(ffi): Remove Room::is_tombstoned.
This patch removes the `Room::is_tombstoned` method as using
`Room::successor_room` plays the same role and its returned value is
always useful.
2025-05-27 17:35:31 +02:00
Ivan Enderlin
da60c1488e feat(ffi): Add the DeduplicateVersions room list filter.
This patch adds `RoomListEntriesDynamicFilterKind::DeduplicateVersions`
to use `new_filter_deduplicate_versions`.
2025-05-27 17:35:31 +02:00
Ivan Enderlin
f65893d65e doc(base): Remove a useless link reference. 2025-05-27 17:35:31 +02:00
Ivan Enderlin
3e89b6b8f9 feat(ffi): Add SuccessorRoom and PredecessorRoom.
This patch removes `RoomTombstoneInfo` and replaces it by
`SuccessorRoom`. This patch renames `RoomInfo::tombstone` to
`RoomInfo::success_room`.

This patch also implements `Room::successor_room()` and
`Room::predecessor_room()`, and adds documentation.
2025-05-27 17:35:31 +02:00
Mauro
7531167824 feat: Let the media preview config return an optional
This allows applications to decide what they'd like to do if there isn't a value present. It allows the application to decide what the default should be.
2025-05-27 16:24:41 +02:00
Ivan Enderlin
d24e269ecc doc(ui): Fix typos. 2025-05-27 14:02:21 +02:00
Ivan Enderlin
88c18c5499 feat(ui): New Room List filter: deduplicate_versions.
This patch adds the new `deduplicate_versions`. This new filter will
filter out room versions that are outdated. Only the “active” versions
are kept.

A room version is considered active if and only if:

* the room is joined and has no successor,
* the room is joined and has a successor room that is invited or knocked,
* the room is left, invited, banned or knocked.

All other rooms are filtered out.
2025-05-27 14:02:21 +02:00
Ivan Enderlin
d0f1e6ce6d chore(base): Expose the new SuccessorRoom and PredecessorRoom types.
This patch makes the `SuccessorRoom` and `PredecessorRoom` types public.
2025-05-27 14:02:21 +02:00
Johannes Marbach
10668f20b0 feat(send_queue): Implement sending of MSC4274 galleries (#4977)
This was broken out of
https://github.com/matrix-org/matrix-rust-sdk/pull/4838 and is a step
towards implementing
[MSC4274](https://github.com/matrix-org/matrix-spec-proposals/pull/4274).

* The entry point for sending galleries via the send queue is a new
method
[`RoomSendQueue::send_gallery`](https://github.com/matrix-org/matrix-rust-sdk/pull/4977/files#diff-8752e86459c22cff470d7ca617240dcbdf222c3c6c98be2af2e43ddec071154cR362)
which is a generalization of `RoomSendQueue::send_attachment`.
* `send_gallery` takes as input parameters a
[`GalleryConfig`](https://github.com/matrix-org/matrix-rust-sdk/pull/4977/files#diff-d38d74cec6159cf769c32bed496199146175f05428fc23ab13bc2c629900da3eR283)
(containing info about the gallery itself, such as its caption) and a
vector of
[`GalleryItemInfo`](https://github.com/matrix-org/matrix-rust-sdk/pull/4977/files#diff-d38d74cec6159cf769c32bed496199146175f05428fc23ab13bc2c629900da3eR355)s
(containing info about each image / file / etc. in the gallery).
* `send_gallery` creates the gallery event content via
[`Room:make_message_event`](https://github.com/matrix-org/matrix-rust-sdk/pull/4977/files#diff-474f20e47fdcf60feac3f839a81f82fbb2c1fd0bb406388b0262adb60216ce3bR2281)
which was renamed from `make_attachment_event` to reflect the fact that
it creates general `msgtype` events now.
* `send_gallery` maps the passed item infos into
[`GalleryItemQueueInfo`](https://github.com/matrix-org/matrix-rust-sdk/pull/4977/files#diff-d569f54c7901b5cd660aae77045c80dabbd3c251f0fa5891530469f35941327aR2008)s.
This additional struct allows grouping all the metadata for a single
gallery item together.
* Finally `send_gallery` invokes
[`QueueStorage::push_gallery`](https://github.com/matrix-org/matrix-rust-sdk/pull/4977/files#diff-d569f54c7901b5cd660aae77045c80dabbd3c251f0fa5891530469f35941327aR1294)
which is a generalization of `QueueStorage::push_media`.
* `send_gallery` pushes upload requests for the media and thumbnails to
the queue in a "daisy chain" manner. The first thumbnail (or media if no
thumbnail exists) is pushed as a `QueuedRequestKind::MediaUpload`. The
remaining thumbnails and media are pushed as
`DependentQueuedRequestKind::UploadFileOrThumbnail`s while chaining each
request to the previous one.
* Finally a
[`DependentQueuedRequestKind::FinishGallery`](https://github.com/matrix-org/matrix-rust-sdk/pull/4977/files#diff-42a1a7ebe2446d916c9e013293bafc5eb16fd89bfe89248e3877ef031cc83ef2R265)
is pushed to finalize the gallery upload (analogous to the existing
`FinishUpload` for single media uploads).
* The `FinishGallery` request is handled in
[`QueueStorage::handle_dependent_finish_gallery_upload`](https://github.com/matrix-org/matrix-rust-sdk/pull/4977/files#diff-8752e86459c22cff470d7ca617240dcbdf222c3c6c98be2af2e43ddec071154cR628)
which was modeled after `handle_dependent_finish_upload`.
* To be able to map the temporary event source for each gallery item to
the final `AccumulatedSentMediaInfo`, a hash map is used.
* Using the hash map, the gallery event is then updated to use the
actual media sources via
[`update_gallery_event_after_upload`](https://github.com/matrix-org/matrix-rust-sdk/pull/4977/files#diff-8752e86459c22cff470d7ca617240dcbdf222c3c6c98be2af2e43ddec071154cR104)
and a new method
[`Room::make_gallery_item_type`](https://github.com/matrix-org/matrix-rust-sdk/pull/4977/files#diff-474f20e47fdcf60feac3f839a81f82fbb2c1fd0bb406388b0262adb60216ce3bR2303)
* An [integration
test](https://github.com/matrix-org/matrix-rust-sdk/pull/4977/files#diff-21532ad5467a69489d7913b8da7afd4d618b7e357ce94f769e6e60e395b58055R2048)
has been added to demonstrate the functionality.

This is relatively large, unfortunately, but including everything needed
to actually send the event made it possible to also add a test for it.
It would be nice if the amount of new code could be reduced but I'm
struggling a bit to find ways to integrate galleries with the existing
media uploads further.

- [x] Public API changes documented in changelogs (optional)

---------

Signed-off-by: Johannes Marbach <n0-0ne+github@mailbox.org>
2025-05-27 11:53:05 +02:00
Ivan Enderlin
2537f0a508 refactor(base): Create dispatch_room_member.
This patch extracts a bit of code from `dispatch` in a new response
processor: `dispatch_room_member`. The idea is to clarify the content of
`dispatch` itself.
2025-05-27 10:00:16 +02:00
Ivan Enderlin
1387772589 refactor(base): Remove a BTreeSet clone.
This patch moves the insertion of `new_user_ids` in
`updated_members_in_room` after the use of `new_user_ids` by
`update_or_set_if_room_is_newly_encrypted`. By moving it after, it saves
the need to clone it entirely, thus saving memory allocations.
2025-05-27 10:00:16 +02:00
Ivan Enderlin
c4f9ef2e2e refactor(base): Improve dispatch_and_get_new_users.
This patch renames `dispatch_and_get_new_users` to `dispatch`. This
response processor no longer returns the new user IDs, but they are
written in a mutable reference argument. This argument is
typed by a new private trait: `NewUsers`. This trait is implemented on
`BTreeSet<OwnedUserId>` and on `()`. It helps to avoid allocations when
the new users are not needed.
2025-05-27 10:00:16 +02:00
Benjamin Bouvier
acce75a6dc test: make the test for the previous commit more realistic
This reproduces the issue originally described, where it wasn't possible
to run a /members query in an event handler, because the sync lock was
taken at this point.
2025-05-27 09:09:41 +02:00
aeoncl
5e0704a7c7 fix(sliding sync): don't take the sync lock while handling events
Fixes #5091.
2025-05-27 09:09:41 +02:00
Benjamin Bouvier
206857bc9e feat(ffi): remove the state store when clearing caches
This is a dangerous operation, and requires that the sync service must
be stopped while we're touching this. Since this is an internal method,
that shouldn't be used in most clients anyways (as it usually papers
over actual issues happening elsewhere, on the server for instance), I
kept it simple with a scary doc comment explaining the preconditions,
but we could assert them at runtime, with a little bit more effort.
2025-05-27 08:59:59 +02:00
Benjamin Bouvier
9e1ea5d7d3 feat(sdk): expose the state store database name 2025-05-27 08:59:59 +02:00
Hugh Nimmo-Smith
e90b105b36 feat(sdk): Add support for MSC4286
This patch updates Ruma to include support for the mx-external-payment-details span attribute from MSC4286.
2025-05-27 08:47:56 +02:00
dependabot[bot]
40ffd404e8 chore(deps): bump tj-actions/changed-files
Bumps [tj-actions/changed-files](https://github.com/tj-actions/changed-files) from 480f49412651059a414a6a5c96887abb1877de8a to c6634ca281a9fc05b03bee224ba00910cb78ab6e.
- [Release notes](https://github.com/tj-actions/changed-files/releases)
- [Changelog](https://github.com/tj-actions/changed-files/blob/main/HISTORY.md)
- [Commits](480f494126...c6634ca281)

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

Signed-off-by: dependabot[bot] <support@github.com>
2025-05-26 17:05:29 +02:00
Benjamin Bouvier
b6b9dc8c1a fix(test): make the test_monthly_divider_mode test pass all on timezones 2025-05-26 15:39:04 +02:00
Benjamin Bouvier
4a397f5ab4 refactor(ffi): pass the UTD hook when constructing a Room from the room list (again!) 2025-05-26 14:48:16 +02:00
Benjamin Bouvier
be927730fa refactor(ffi): get rid of RoomListItem
It is simply a Room now.
2025-05-26 14:48:16 +02:00
Benjamin Bouvier
81036da44c refactor(ffi): rename the SDK Room import to SdkRoom 2025-05-26 14:48:16 +02:00
Benjamin Bouvier
b016f60e46 refactor(ffi): move methods from RoomListItem to Room
Only code motion. Most methods already existed on the `Room` impl block.
2025-05-26 14:48:16 +02:00
Benjamin Bouvier
cd76cec089 refactor(ffi): also pass the UTD hook to the notification client 2025-05-26 14:48:16 +02:00
Benjamin Bouvier
820c73dd2f refactor(ffi): get rid of the timeline stored in a Room 2025-05-26 14:48:16 +02:00
Benjamin Bouvier
42a4a6c1a8 refactor(ui): get rid of the RoomListService::Room wrapper
It's just a room, now! Since there were some users of the
`latest_event()` that returned an `EventTimelineItem`, I kept this
method as a method in the Room trait extension that's in the UI crate,
so it's still convenient to use.
2025-05-26 14:48:16 +02:00
Ivan Enderlin
eec9a067be fix(sdk): Continue leaving a room if server replies with 403.
This patch updates `Room::leave` to not early return when the server
returns a 403 error code on `/leave`. Indeed, if the user doesn't have
the permissions to leave a room, it's impossible for they to leave it.
Let's consider it's fine to ignore this particular error and continue
the process of leaving the room.
2025-05-26 14:42:17 +02:00
Jorge Martín
e53eaf4213 refactor: Fetch the ignored user list account data from the store for Client::is_user_ignored
Also move it to `BaseClient` instead.
2025-05-26 13:02:58 +02:00
Jorge Martín
a3725b6b24 fix: Do not retrieve notification events sent by ignored users 2025-05-26 13:02:58 +02:00
Stefan Ceriu
f0c7370637 feat(ffi): expose the inviter directly on the room to avoid having to fetch the room preview
The room preview doesn't actually contain the inviter but instead retrieves it from the room invite details.
2025-05-24 10:49:44 +03:00
Yousef Moazzam
f108840e28 test: put repeated event field values into variables 2025-05-23 14:12:14 +01:00
Yousef Moazzam
f4f63a7e41 test: create plain text room event with EventFactory 2025-05-23 14:12:14 +01:00
Ivan Enderlin
26afd890ce test(base): Use EventFactory instead of JSON hardcoded value.
This patch updates two tests to use the `EventFactory` to replace JSON
hardcoded values to represent the events.
2025-05-23 11:35:53 +02:00
Ivan Enderlin
bfac815a5e test: EventBuilder<RoomCreateEventContent> can set predecessor.
This patch adds the `predecessor` and `no_predecessor` methods on
`EventBuilder<RoomCreateEventContent>`. This is helpful to configure the
`predecessor` field.
2025-05-23 11:35:53 +02:00
Ivan Enderlin
95e8d0589b test: Fix EventFactory::create.
This patch fixes `EventFactory::create` where the `m.room.create` wasn't
created as a state-event (the `state_key` field was missing).

Also, it uses the `creator_user_id` in the `sender` field if no sender
was given.
2025-05-23 11:35:53 +02:00
Ivan Enderlin
16a923edda test: Simplify EventBuilder::into_raw_timeline.
This patch simplifies `EventBuilder::into_raw_timeline`. It is exactly
like `EventBuilder::into_raw`, so let's use it.
2025-05-23 11:35:53 +02:00
Ivan Enderlin
9c227c2321 feat(base): Add Room::successor_room and Room::predecessor_room.
First off, this patch renames `Room::tombstone` to
`Room::tombstone_content` (to be consistent with other methods, such as
`Room::create_content`).

Second, this patch adds the `Room::successor_room` and
`Room::predecessor_room` methods, along with the `SuccessorRoom` and
`PredecessorRoom` types. This naming more or less comes from the Matrix
specification:

- the term _predecessor_ is part of the specification,
- the term _successor_ isn't present _per se_, the words _replacement
  room_ are used instead, but I prefer _successor_ as it brings a nice
  symmetry with _predecessor_.
2025-05-23 11:35:53 +02:00
Ivan Enderlin
5d617da74c chore(base): Move the Room::*tombstone* methods in new tombstone module.
This patch moves the `Room::is_tombstoned` and `Room::tombstone` methods
in the new `tombstone` module.
2025-05-23 11:35:53 +02:00
Jonas Platte
3aa356dcd6 chore: Use shorter syntax for workspace inheritance where possible 2025-05-23 10:23:36 +02:00
Jonas Platte
491f7cd529 chore: Clean up Cargo.toml formatting 2025-05-23 10:23:36 +02:00
Timo
6d5ad4eddc feat(widget-driver): Add to-device support
The widget Driver should be able to send and receive to-device events.
This is useful for element call encryption keys.

This PR focusses on the widget driver and machine logic. To
send/communicate the events from the widget to the driver.

It skips any encryption logic. Some of the encryption logic will be part
of crypto crate and the code in the widget driver crate should be kept
minimal once the crypto crate is ready.

---------

Co-authored-by: Valere <bill.carson@valrsoft.com>
2025-05-22 13:38:28 +02:00
Yousef Moazzam
ec638e017b test: remove import of unused sync_timeline_event! macro in shield test 2025-05-22 12:46:56 +02:00
Yousef Moazzam
8f693f4615 test: create plain text room event with EventFactory 2025-05-22 12:46:56 +02:00
Jorge Martín
fe8f77ed93 refactor: when leaving an Invited room also forget it
This behaviour was added only at the `RoomPreview::leave` method, but since we're slowly moving away from it we should move the forget action to the `Room::leave` method instead
2025-05-22 12:07:19 +02:00
Benjamin Bouvier
5c6238f132 chore(deps): bump wasm-bindgen-test 2025-05-22 11:50:13 +02:00