Commit Graph

14718 Commits

Author SHA1 Message Date
Ivan Enderlin
0ce36d0bfb fix(sdk): EventCacheInner::all_caches_for_room returns a reference to Caches.
This patch updates `EventCacheInner::all_caches_for_rooms` by returning
an `OwnedRwLockReadGuard` instead of `Caches`. `Caches` no longer
implement `Clone`, which prevents cloning all the event caches per room
when we need only one for example.

`Caches` has two new methods: `handle_joined_room_update` and
`handle_left_room_update`. This type acts more like a dispatcher now,
which was the initial idea. That way, we don't need to dispatch manually
on all event caches: `Caches` is responsible for that.

We need to be a bit careful now since `all_caches_for_rooms` returns an
owned read-lock over `EventCacheInner::by_room`.
2026-03-12 10:07:05 +01:00
Ivan Enderlin
9608aa5840 chore(sdk): Add Caches::all_events.
This patch adds the `Caches::all_events` to iterate over all events from
all caches.
2026-03-12 10:07:05 +01:00
Ivan Enderlin
99c7e27fcf fix(sdk): Introduce ResetCaches.
This patch introduces the `Caches::prepare_to_reset` method, which
returns a `ResetCaches` type. This new type is responsible to lock all
the event caches related to a room, and to reset their in-memory state
with `ResetCaches::reset_all`. This patch fixes 2 bugs (see below).

This type is acquiring exclusive locks over all the event caches
managed by `Caches`. Once dropped, all the locks are released. Note that
`ResetCaches::reset_all` takes `self`, not `&self` or `&mut self`, i.e.
it consumes `ResetCaches`, ensuring the locks are _always_ released.

This patch also fixes a possible bug when acquiring the exclusive
locks could have failed, but the error wasn't stopping the execution;
the database would have been reset anyway. Now, `try_join_all` is used
before and after resetting the database (prior to this patch, it was
using `join_all` before resetting the database).

This patch also ensures that only one reset per `Caches` can
happen at a time, by making `Caches::prepare_to_reset` taking a
`&mut self`. This was partially supported by the write lock over
`EventCacheInner::by_room`, but it would have still been possible to
reset the same `Caches` concurrently.
2026-03-12 10:07:05 +01:00
Ivan Enderlin
74fc96eec2 chore(sdk): Creates the Caches type.
This patch is the first step for the `Caches` type. It creates it, along
with the `new` constructor. More changes are required, but this is a
first step.

The pattern `Caches { room }` is used everywhere where a
`RoomEventCache` was read previously, so that we are sure the type
system will complain when we will add more fields to `Caches` (like for
threads and pinned events).
2026-03-12 10:07:05 +01:00
Stefan Ceriu
791f4bc871 feat(sentry): add final app version and platform configuration options next to the sentry dsn 2026-03-11 15:59:32 +02:00
rasmus
f812afca21 doc(sdk): add CHANGELOG.md entry for add_mentions field in Event
Signed-off-by: rasmus <mail@rasmusantons.de>
2026-03-11 14:20:40 +01:00
rasmus
dd1c16a873 test(sdk): add tests for reply events with and without add_mentions
Signed-off-by: rasmus <mail@rasmusantons.de>
2026-03-11 14:20:40 +01:00
rasmus
999d612a33 feat(sdk): add add_mentions toggle to Reply
Signed-off-by: rasmus <mail@rasmusantons.de>
2026-03-11 14:20:40 +01:00
Kévin Commaille
f25af6be6b fix(ffi): Don't assume that all redacted state events have an empty content
Signed-off-by: Kévin Commaille <zecakeh@tedomum.fr>
2026-03-11 10:34:41 +01:00
dependabot[bot]
af8236d708 chore(deps): bump quinn-proto from 0.11.13 to 0.11.14
Bumps [quinn-proto](https://github.com/quinn-rs/quinn) from 0.11.13 to 0.11.14.
- [Release notes](https://github.com/quinn-rs/quinn/releases)
- [Commits](https://github.com/quinn-rs/quinn/compare/quinn-proto-0.11.13...quinn-proto-0.11.14)

---
updated-dependencies:
- dependency-name: quinn-proto
  dependency-version: 0.11.14
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
2026-03-11 09:04:19 +02:00
Stefan Ceriu
0cdaf8d794 change(live_location): emit the last becon_info asset type when subscribing to live location shares instead of none 2026-03-11 09:02:37 +02:00
Stefan Ceriu
6b414b7791 change(location_sharing): make the asset type non-optional as per original MSC instructions
- https://github.com/matrix-org/matrix-spec-proposals/blob/matthew/location/proposals/3488-location.md
- `If m.asset is missing from the location's content the client should render it as m.self as that will be the most common use case. Otherwise, if it's not missing but the type is invalid or unknown the client should attempt to render it as a generic location. Clients should be able to distinguish between m.self and explicit assets for this feature to be correctly implemented as interpreting everything as m.self is unwanted.`
- this aligns the behavior with the newly introduced live location asset type handling
2026-03-11 09:02:37 +02:00
mgoldenberg
4ec9124ce1 Allow storing the same Event in multiple LinkedChunks of the same Room (#6200)
# Overview

There are scenarios in which it is sensible to have an event exist in
the same room more than once. Notably, this is true in the context of a
thread, where an event exists in the main timeline of a room, as well as
in a thread of that same room.

Support for this behavior has been implemented in the
`SQLiteEventCacheStore` in #6065; however, this was never implemented
for the `IndexeddbEventCacheStore` or the `MemoryStore`. This pull
request extends this behavior to both of those stores.

# Changes

## Integration Tests
First, `test_event_chunks_allows_same_event_in_room_and_thread` was
moved from `matrix_sdk_sqlite::event_cache_store` to
`matrix_sdk_base::event_cache::store::integration_tests`. Then, a few
additional integration tests were added to ensure that behavior is
consistent across implementations of `EventCacheStore`.

## `IndexeddbEventCacheStore`
In order to accommodate the behavioral changes specified by the
integration tests, it was necessary to modify the schema in the
IndexedDB implementation of `EventCacheStore`. Namely, the events object
store was cleared and removed and then replaced with a nearly identical
one, the only difference being the removal of a uniqueness constraint on
one of the indices.

The remaining changes mostly involved updating the behavior of top-level
`EventCacheStore` functions - e.g., filtering out events where they were
duplicated or removing positioning information where it was not
relevant.

## `MemoryStore`
The changes to `MemoryStore` mostly involved updating the behavior of
top-level `EventCacheStore` function - e.g., filtering out events where
they were duplicated or removing positioning information where it was
not relevant.

That being said, it also involved some breaking changes to
`RelationalLinkedChunk`.

1. `RelationalLinkedChunk::items` - this function returned an `Iterator`
that did not contain information about the `LinkedChunkId`, so this
information was added to the items in the `Iterator`.
2. `RelationalLinkedChunk::save_item` - this function did not update the
item in all linked chunks of the provided `Room`. It now does this, but
requires that the provided `Item` be `Clone`.

(1) could probably have been a new function, but I thought a nicer
interface was worth the breaking change. (2) could probably be prevented
by re-organizing `RelationalLinkedChunk`'s internal data structures to
remove the `Clone` requirement, but that seemed like it could turn into
a large refactoring project, so I opted for something simpler albeit
somewhat crude.

In both cases, I'm open to suggestions and would be happy to revisit if
something else is preferred.

---
Closes #6094.

- [x] I've documented the public API Changes in the appropriate
`CHANGELOG.md` files.
- [x] I've read [the `CONTRIBUTING.md`
file](https://github.com/matrix-org/matrix-rust-sdk/blob/main/CONTRIBUTING.md),
notably the sections about Pull requests, Commit message format, and AI
policy.
- [ ] This PR was made with the help of AI.

Signed-off-by: Michael Goldenberg <m@mgoldenberg.net>

---------

Signed-off-by: Michael Goldenberg <m@mgoldenberg.net>
2026-03-10 14:55:02 +01:00
mgoldenberg
b65e450813 Support TLS v1.3 on all platforms (#6053)
**Note:** _this pull request has a companion pull request in the
[`complement-crypto`](https://github.com/matrix-org/complement-crypto/pull/229)
repository, which must be merged in conjunction with this one._

_Before merging, this should be tested in conjunction with the Element X
iOS client to ensure that TLS v1.3 is working properly._ @stefanceriu
has agreed to work on this.

## Overview

The primary change in this pull request upgrades the `reqwest`
dependency to its latest version, which defaults to using `rustls` with
support for `rustls-platform-verifier` instead of `native-tls` (see
[`reqwest@0.13.0`](https://github.com/seanmonstar/reqwest/releases/tag/v0.13.0)).
The benefit here is that `rustls` supports TLS v1.3 on all platforms,
whereas [`native-tls` does
not](https://github.com/sfackler/rust-native-tls/pull/278).

Additionally, this pull request makes `rustls` the default TLS
implementation in all the crates in this repository.

This will be particularly helpful with element-hq/element-x-ios#786.

## Changes

- `reqwest` bumped to `0.13.1`
- The API for adding/replacing certificates has changed a bit, so this
required some updating in `HttpSettings::make_client`
- `oauth2-reqwest` added in favor of `oauth2/reqwest` 
    - This is required in order to be compatible with `reqwest^0.13`
- _**`oauth2-reqwest` is currently in alpha release, so it probably
makes sense to let this stabilize a bit.**_ For details, see
https://github.com/ramosbugs/oauth2-rs/issues/333#issuecomment-3906712203.
- `getrandom` bumped to `0.3.4`
    - This is required in order to be compatible with `oauth2@5.1.0`
- `proptest` bumped to `1.9.0`
    - This is required in order to be compatible with `getrandom@0.3.4` 
- Make `rustls` the default TLS implementation

## Questions

### Mirror feature flag names?

A number of feature flags have been replaced in the dependencies above.

1. _**`reqwest/rustls-tls` => `reqwest/rustls`**_ - this is simply a
name change, but is semantically identical (see
[`reqwest@0.13.0`](https://github.com/seanmonstar/reqwest/releases/tag/v0.13.0)).
2. _**`getrandom/js` => `getrandom/wasm_js`**_ - the semantics here have
changed slightly, but it seems to just make it easier to enable the
`wasm_js` backend (see
[`getrandom@0.3.4`](https://github.com/rust-random/getrandom/blob/master/CHANGELOG.md#major-change-to-wasm_js-backend)).

At any rate, I have updated references to these flags in each of the
various `Cargo.toml` files, but have not changed the names of our
exposed features to mimic those in the dependencies.

Any thoughts or preferences on whether to mirror those names? That
would, of course, result in a breaking change.

### Default to using `rustls`? Deprecate `native-tls`?

Now that the dependencies have all been bumped, we can use `rustls` on
all platforms. Should this be the new default given that `native-tls`
will very likely never support TLS v1.3 on Apple devices? And should
`native-tls` be deprecated as a result?

**UPDATE:** _The consensus here seems to be that we should default to
using `rustls`, but that `native-tls` should still be available._

---
Fixes #5800.


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

Signed-off-by: Michael Goldenberg <m@mgoldenberg.net>

---------

Signed-off-by: Michael Goldenberg <m@mgoldenberg.net>
2026-03-10 13:38:18 +01:00
dependabot[bot]
cee74d4965 chore(deps): bump bnjbvr/cargo-machete
Bumps [bnjbvr/cargo-machete](https://github.com/bnjbvr/cargo-machete) from 6456c7b34a8c1245e0c186ac50c56666ccbd44f1 to 8a8e0cd1046f54206f6d2e050cf028e6db9dbc75.
- [Release notes](https://github.com/bnjbvr/cargo-machete/releases)
- [Changelog](https://github.com/bnjbvr/cargo-machete/blob/main/CHANGELOG.md)
- [Commits](6456c7b34a...8a8e0cd104)

---
updated-dependencies:
- dependency-name: bnjbvr/cargo-machete
  dependency-version: 8a8e0cd1046f54206f6d2e050cf028e6db9dbc75
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>
matrix-sdk-ffi/20260310
2026-03-10 10:41:01 +01:00
dependabot[bot]
a845bdf26a chore(deps): bump CodSpeedHQ/action from 4.11.0 to 4.11.1
Bumps [CodSpeedHQ/action](https://github.com/codspeedhq/action) from 4.11.0 to 4.11.1.
- [Release notes](https://github.com/codspeedhq/action/releases)
- [Changelog](https://github.com/CodSpeedHQ/action/blob/main/CHANGELOG.md)
- [Commits](2ac5728517...281164b0f0)

---
updated-dependencies:
- dependency-name: CodSpeedHQ/action
  dependency-version: 4.11.1
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2026-03-10 11:25:57 +02:00
dependabot[bot]
40ff661358 chore(deps): bump tj-actions/changed-files from 47.0.4 to 47.0.5
Bumps [tj-actions/changed-files](https://github.com/tj-actions/changed-files) from 47.0.4 to 47.0.5.
- [Release notes](https://github.com/tj-actions/changed-files/releases)
- [Changelog](https://github.com/tj-actions/changed-files/blob/main/HISTORY.md)
- [Commits](https://github.com/tj-actions/changed-files/compare/v47.0.4...v47.0.5)

---
updated-dependencies:
- dependency-name: tj-actions/changed-files
  dependency-version: 47.0.5
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2026-03-09 17:29:19 +01:00
Andy Balaam
9de2d70bad Provide recover_and_fix_backup method to fix backup if needed (#6252)
Part of https://github.com/element-hq/element-meta/issues/3059
2026-03-09 13:32:04 +00:00
Benjamin Bouvier
6d141c07bc refactor(test): use the event factory in the notable reason read receipt update test
Turns out, the `m.read` event was invalid, because it should've been
part of the ephemeral events in the sync response (and not part of the
room's timeline response), so the event was dismissed. The test already
passed while behaving this way, so let's make it reflect what it did
indeed.
2026-03-09 14:16:52 +01:00
Benjamin Bouvier
608091fbe7 fix(test): fix test_read_receipt_can_trigger_a_notable_update_reason expectations
The test was aborted just a bit too early, in that if you introduce
arbitrary sleep statements, it would fail because the stream of notable
reasons updates wouldn't be empty, and include two `LATEST_EVENT`
updates instead.

It's not clear why we get the second update, but this isn't critical to
fix at the moment, so I'll leave this as an exercise to the reader.
2026-03-09 12:45:40 +01:00
Kévin Commaille
5e1c917459 refactor(sdk): Take a UrlOrQuery in MatrixAuth::login_with_sso_callback
To make it more convenient to use with `LocalServerBuilder` /
`LocalServerRedirectHandle`.

Signed-off-by: Kévin Commaille <zecakeh@tedomum.fr>
2026-03-09 11:49:51 +01:00
Kévin Commaille
3e5e6efb31 refactor(sdk): Move UrlOrQuery into utils module
This will allow to reuse it outside of the `oauth` module.

It can now also be converted from a `QueryString`, for improved
compatibility with `LocalServerRedirectHandle`.

Signed-off-by: Kévin Commaille <zecakeh@tedomum.fr>
2026-03-09 11:49:51 +01:00
Ivan Enderlin
5902a857d9 fix(xtask): log overview sanitizes HTML.
The log message can contain HTML data. It happens notably when the
homeserver is broken, and an HTML document is returned in some errors.
We don't want to parse the fields in this case, because HTML breaks
everything.
2026-03-09 11:26:44 +01:00
Kévin Commaille
168fd7232e refactor(sdk): Remove TODOs by using new Ruma API
Signed-off-by: Kévin Commaille <zecakeh@tedomum.fr>
2026-03-09 10:44:56 +01:00
Kévin Commaille
e17ca1071c Upgrade Ruma after Typing breaking change
Signed-off-by: Kévin Commaille <zecakeh@tedomum.fr>
2026-03-09 09:18:19 +00:00
Kévin Commaille
99ac38eb20 Upgrade Ruma after SecretEncryptedData breaking change
Signed-off-by: Kévin Commaille <zecakeh@tedomum.fr>
2026-03-09 09:18:19 +00:00
Kévin Commaille
698ffba88e Upgrade Ruma after report_content breaking change
Signed-off-by: Kévin Commaille <zecakeh@tedomum.fr>
2026-03-09 09:18:19 +00:00
Kévin Commaille
23a312ed68 Upgrade ruma after ErrorKind::Forbidden breaking change
Signed-off-by: Kévin Commaille <zecakeh@tedomum.fr>
2026-03-09 09:18:19 +00:00
Kévin Commaille
1f69fcb80b Upgrade Ruma after RequestAction breaking changes
Signed-off-by: Kévin Commaille <zecakeh@tedomum.fr>
2026-03-09 09:18:19 +00:00
Kévin Commaille
deabb8b6e7 refactor(ui): Construct PossiblyRedactedPinnedEventsEventContent from PinnedEventsEventContent
It is simpler than going through deserialization.

Signed-off-by: Kévin Commaille <zecakeh@tedomum.fr>
2026-03-09 09:01:39 +01:00
Kévin Commaille
d8cbb1b77b refactor(ui): Call membership_change() on the event rather than providing the parts manually
Signed-off-by: Kévin Commaille <zecakeh@tedomum.fr>
2026-03-09 09:01:39 +01:00
Kévin Commaille
7c16d673fb benchmarks: Use realistic Matrix IDs in timeline
We rely on the EventFactory to generate a hash of the events for the
event IDs, and we use the appropriate length for room IDs.

Signed-off-by: Kévin Commaille <zecakeh@tedomum.fr>
2026-03-06 15:00:45 +01:00
Kévin Commaille
e9fbbb52d5 benchmarks: Use realistic Matrix IDs in store_bench
Use the appropriate length for room IDs.

Signed-off-by: Kévin Commaille <zecakeh@tedomum.fr>
2026-03-06 15:00:45 +01:00
Kévin Commaille
c05df39132 benchmarks: Use realistic Matrix IDs in room_list
We rely on the EventFactory to generate a hash of the events for the
event IDs, and we use the appropriate length for room IDs.

Signed-off-by: Kévin Commaille <zecakeh@tedomum.fr>
2026-03-06 15:00:45 +01:00
Kévin Commaille
d572d201c9 benchmarks: Use realistic Matrix IDs in room_bench
We generate an arbitrary hash for the event IDs, and we use the
appropriate length for room IDs.

Signed-off-by: Kévin Commaille <zecakeh@tedomum.fr>
2026-03-06 15:00:45 +01:00
Kévin Commaille
39aa777b9b benchmarks: Use realistic Matrix IDs in linked_chunk
We rely on the EventFactory to generate a hash of the events for the
event IDs, and we use the appropriate length for room IDs.

Signed-off-by: Kévin Commaille <zecakeh@tedomum.fr>
2026-03-06 15:00:45 +01:00
Kévin Commaille
f0ae0e53f9 benchmarks: Use realistic Matrix IDs in event_cache
We rely on the EventFactory to generate a hash of the events for the
event IDs, and we use the appropriate length for room IDs.

Signed-off-by: Kévin Commaille <zecakeh@tedomum.fr>
2026-03-06 15:00:45 +01:00
Kévin Commaille
7ec331c842 testing: Create realistic modern event IDs in EventFactory
As a fallback when the ID is not provided when constructing the event.
It allows to work with data that looks like what we would get in
production, which is important for benchmarks.

Signed-off-by: Kévin Commaille <zecakeh@tedomum.fr>
2026-03-06 15:00:45 +01:00
Skye Elliot
8472b5504e Merge pull request #6215 from matrix-org/kaylendog/history-sharing/restart-import
feat: Try import stored key bundles on client start
2026-03-05 16:23:36 +00:00
Skye Elliot
2ca717b4af docs: Update CHANGELOGs
Signed-off-by: Skye Elliot <actuallyori@gmail.com>
2026-03-05 15:55:03 +00:00
Skye Elliot
c864fac823 test(sdk): De-duplicate shared history integration tests
Signed-off-by: Skye Elliot <actuallyori@gmail.com>
2026-03-05 15:55:03 +00:00
Skye Elliot
c62da4a026 tests(sdk): Add integration test for bundle import crash recovery
Signed-off-by: Skye Elliot <actuallyori@gmail.com>
2026-03-05 15:55:03 +00:00
Skye Elliot
471e045ea3 feat(sdk): Remove pending key bundle on HTTP failure
Signed-off-by: Skye Elliot <actuallyori@gmail.com>
2026-03-05 15:55:02 +00:00
Skye Elliot
29ca03bb81 feat(sdk): Clear room pending key bundle for expired details
Signed-off-by: Skye Elliot <actuallyori@gmail.com>
2026-03-05 15:55:02 +00:00
Skye Elliot
29e3b7766d feat(sdk): Separate startup bundle import to different task
Signed-off-by: Skye Elliot <actuallyori@gmail.com>
2026-03-05 15:55:02 +00:00
Skye Elliot
2dd43fc9de feat(sdk): Add proper error logging and comments
Signed-off-by: Skye Elliot <actuallyori@gmail.com>
2026-03-05 15:55:02 +00:00
Skye Elliot
7fbc3e78e9 feat(sdk): Try import stored room key bundles on startup
Signed-off-by: Skye Elliot <actuallyori@gmail.com>
2026-03-05 15:55:02 +00:00
Skye Elliot
ac6ccd3384 refactor(sdk): Move should_accept_bundle into shared_room_history
Signed-off-by: Skye Elliot <actuallyori@gmail.com>
2026-03-05 15:55:02 +00:00
Benjamin Bouvier
f49784a15e refactor(crypto): use an async closure in Store::with_transaction
This allows passing the `Transaction` by mutable reference, instead of
passing it by ownership and requiring the callback to pass it back,
which is slightly better in terms of ergonomics. This was hard to
achieve without async closures, but now that we have them, this is
trivial.
2026-03-05 15:51:34 +01:00
Benjamin Bouvier
b0aadd1574 refactor(test): use assert_let_timeout more often
Many of our tests make use of `assert_let` for checking that some value
comes out of a stream, while they could use `assert_let_timeout`, which
provides better ergonomics when the expected value doesn't arrive
immediately, by failing quickly.

This converts a few instances, making those tests easier to debug in the
future, would they fail again.
2026-03-05 15:36:41 +01:00