Commit Graph

11007 Commits

Author SHA1 Message Date
Ivan Enderlin
714caae545 chore(sqlite): Remove a useless indentation.
This patch removes a useless indentation.
2025-02-12 16:13:40 +01:00
Andy Balaam
25bb607b27 feat(crypto): Allow fetching encryption info using session ID 2025-02-12 14:00:14 +00:00
Andy Balaam
c9a6ae9549 fix(tests): Prevent test flake by using different names for the test stores 2025-02-12 13:45:20 +00:00
Benjamin Bouvier
58099fd6b5 test(timeline): add new tests for fetching replies that are UTD or sticker or polls 2025-02-12 14:28:17 +01:00
Benjamin Bouvier
c5856a33f0 test(timeline): rewrite and comment fetch_details() test 2025-02-12 14:28:17 +01:00
Benjamin Bouvier
a5f115f21f test(timeline): use the MatrixMockServer in integration/timeline/replies 2025-02-12 14:28:17 +01:00
Benjamin Bouvier
ddd84e231b feat(timeline): support more timeline item content kinds in replied-to details 2025-02-12 14:28:17 +01:00
Benjamin Bouvier
51e9df87f5 chore(timeline): add some logs when fetching a reply details 2025-02-12 14:28:17 +01:00
Benjamin Bouvier
aec4d37a2e refactor(event cache): fold all_deduplicated computation into collect_valid_and_duplicated_events 2025-02-12 14:10:14 +01:00
Benjamin Bouvier
ceafc2155f refactor(event cache): move the Deduplicator instance to RoomEventCacheState
The `RoomEvents` doesn't hold the `Deduplicator` instance now, it's the
role of the `RoomEventCacheState`. This slightly simplifies the code, in
a few cases.
2025-02-12 14:10:14 +01:00
Benjamin Bouvier
4a37d6ebe2 refactor(event cache): move remove_events_and_update_insert_position to the public impl block
Only code motion.
2025-02-12 14:10:14 +01:00
Benjamin Bouvier
10095f8627 refactor(event cache): rename RoomEvents::remove_events to remove_events_by_id
And move it to the public implementation.

Only code motion and renaming, no changes in functionality.
2025-02-12 14:10:14 +01:00
Benjamin Bouvier
84bb1ab595 refactor(event cache): extract deduplication outside the RoomEvents events methods 2025-02-12 14:10:14 +01:00
Ivan Enderlin
fce7999890 chore(common) Split the test_insert_items_at tests.
This patch splits the `test_insert_items_at` test into 5 tests.
2025-02-11 17:32:20 +01:00
Ivan Enderlin
10b72ef4b4 test(common): Update test_replace_item.
This patch updates the `test_replace_item` test to ensure
`Update::ReplaceItem` is correct.
2025-02-11 17:32:20 +01:00
Ivan Enderlin
bfbb354c39 chore(common): Split a test into 3 tests.
This patch splits the `test_replace_at` test into 3 smaller tests.
2025-02-11 17:32:20 +01:00
Ivan Enderlin
9db137af44 refactor(common): LinkedChunk can start by a gap.
This patch removes the invariant stating that a `LinkedChunk` must start
by a chunk of type items. This has never been really useful but it's now
annoying to have this (with iterative loading of a `LinkedChunk` via the
`EventCache`, it's now possible to get a gap as the first chunk). Let's
remove this invariant.
2025-02-11 17:32:20 +01:00
Stefan Ceriu
2999d10fb9 fix(ffi): check that our own device is cross-signed before responding to incoming user verification requests 2025-02-11 16:39:26 +02:00
Kévin Commaille
654885a925 fix(ui): Demote aggregation target not found log to TRACE level
We encountered this warning a lot in the logs after upgrading the SDK today.

My understanding is that this path is expected if the event is not yet in the timeline, so it's nothing to warn about.

Signed-off-by: Kévin Commaille <zecakeh@tedomum.fr>
2025-02-11 15:37:35 +01:00
Damir Jelić
8042abe5f5 fix(recovery): Delete the known secrets from 4s when disabling recovery 2025-02-11 15:28:33 +01:00
Kévin Commaille
65ee18a52d feat(sqlite): Run VACUUM operation after removing a room
A room can be associated to a lot of data, depending on the number of members in the room.
So freeing space on the filesystem should be worth it in some cases.

An (extreme) example: I have a test account that is in ~60 rooms, a few of those big public rooms, including Matrix HQ. The size of the matrix-sdk-state.sqlite3 file is 542 MB. Using this PR and leaving, then forgetting Matrix HQ brings the DB down to 255 MB.
2025-02-11 14:13:25 +00:00
Benjamin Bouvier
69588d5266 test(timeline): use a builder pattern to create a TestTimeline 2025-02-11 11:26:47 +01:00
Benjamin Bouvier
7b77b19bc0 refactor(timeline): get rid of the optional in is_room_encrypted field
The `EventTimelineItem` would get from a bool to an `Option<bool>`. If
the metadata's `is_room_encrypted` was set to `None`, then it would use
`false` as the value, before wrapping it again into an `Option`.

Since the only reader of `EventTimelineItem::is_room_encrypted()`
doesn't really care about the difference between `Some(false)` and
`None`, in `EventTimelineItem::get_shield()`, we can use a plain `bool`
instead of an `Option`, and not distinguish `Some(false)` from `None`.
At worst, it means that sometimes we don't know the room encryption
status yet, and consider the room unencrypted; as soon as we'll get an
update about encryption state, all the items will be marked as encrypted
anyways, if needs be.
2025-02-11 11:26:47 +01:00
Benjamin Bouvier
357b36b287 refactor(timeline): simplify transition from unencrypted -> encrypted 2025-02-11 11:26:47 +01:00
Benjamin Bouvier
a5f0473e1b test(timeline): use the MatrixMockServer and EventFactory in integration/timeline/mod.rs 2025-02-11 11:26:47 +01:00
Stefan Ceriu
8d74d46d80 chore(ffi): expose UserIdentity was_previously_verified and has_verification_violation methods 2025-02-10 18:28:55 +02:00
Benjamin Bouvier
9f2c572709 fix(timeline): maintain aggregations when an event is deduplicated (#4576)
## Some context

An aggregation is an event that relates to another event: for instance,
a
reaction, a poll response, and so on and so forth.
                               
## Some requirements
                                              
Because of the sync mechanisms and federation, it can happen that a
related
event is received *before* receiving the event it relates to. Those
events
must be accounted for, stashed somewhere, and reapplied later, if/when
the
related-to event shows up.
In addition to that, a room's event cache can also decide to move events
around, in its own internal representation (likely because it ran into
some
duplicate events, or it managed to decrypt a previously UTD event).
When that happens, a timeline opened on the given room
will see a removal then re-insertion of the given event. If that event
was
the target of aggregations, then those aggregations must be re-applied
when
the given event is reinserted.
                                                                       
## Some solution
      
To satisfy both requirements, the [`Aggregations`] "manager" object
provided
by this PR will take care of memoizing aggregations, **for the entire
lifetime of the timeline** (or until it's clear'd by some
caller). Aggregations are saved in memory, and have the same lifetime as
that of a timeline. This makes it possible to apply pending aggregations
to cater for the first use case, and to never lose any aggregations in
the
second use case.

## Some points for the reviewer

- I think the most controversial point is that all aggregations are
memoized for the entire lifetime of the timeline. Would that become an
issue, we can get back to some incremental scheme, in the future:
instead of memoizing aggregations for the entire lifetime of the
timeline, we'd attach them to a single timeline item. When that item is
removed, we'd put the aggregations back into a "pending" stash of
aggregations. If the item is reinserted later, we could peek at the
pending stash of aggregations, remove any that's in there, and reapply
them to the reinserted event. This is what the [first version of this
patch](ec64b9e0bc)
did, in a much more adhoc way, for reactions only; based on the current
PR, we could do the same in a simpler manner
- while the PR has small commits, they don't quite make sense to review
individually, I'm afraid, as I was trying to find a way to make a
general system that would work not only for reactions, poll responses
and ends. As a matter of fact, the first commits may have introduced
code that is changed in subsequent commits, making the review a bit
hazardous. Happy to have a live reviewing party over Element Call, if
that helps, considering the size of the patch.
- future work may include using the aggregations manager for edits too,
leading to more code removal.
2025-02-10 15:38:25 +00:00
Jorge Martín
4b6dd5c857 fix(ffi): Client::resolve_room_alias was mapping the wrong error type
This is used to check if the alias is resolved or not.
2025-02-10 09:39:00 +01:00
Stefan Ceriu
83dd11ea7d chore(ffi): expose the whole sender profile when receiving a verification request 2025-02-07 11:47:59 +02:00
Jorge Martín
6c2a88cdc0 test: Fix flaky test_publishing_room_alias 2025-02-07 09:00:07 +01:00
Benjamin Bouvier
e00d57fee2 test: wait for the redact endpoint to be hit in test_abort_before_being_sent
The test ends up with checking that the redact endpoint has been hit
once. It's actually the send queue doing the redaction as a dependent
send request, and it doesn't provide any notification mechanism in this
case, so we can't really know when it's done doing it.

One solution would be to not check the number of calls to the redact/
endpoint, but that means checking for fewer things. Instead, I made it
so that when hit, the endpoint will signal it to the main task using a
oneshot channel; then the main task waits with a long timeout for the
receiving end to get the notification it's been sent, which should be
sufficient.
2025-02-06 17:20:04 +01:00
Stefan Ceriu
ce44c6e4e7 chore(base): don't show timeline verification requests as last messages 2025-02-06 14:01:05 +02:00
Stefan Ceriu
f9ff4fff50 feat(ffi): add support for starting and responding to user verification requests 2025-02-06 14:01:05 +02:00
Benjamin Bouvier
2291a61379 ci: add a new feature set to test experimental-oidc too
This would help find test failures specific to experimental-oidc, as
well as doctests failing (which would have prevented the failures fixed
in https://github.com/matrix-org/matrix-rust-sdk/pull/4614 to happen in
the first place).
2025-02-06 11:21:31 +01:00
Stefan Ceriu
d8f37509af chore(ffi): reduce the verbosity of the store locks and ambiguity map 2025-02-05 17:45:57 +02:00
Jorge Martín
dddbcfbabb fix(ffi): Align RoomList::preview_room with Client::get_room_preview_* functions.
This removes the restriction applied in the FFI layer so only invited and knocked rooms can return room previews.
2025-02-05 14:06:50 +01:00
Ivan Enderlin
ed8c1d543a doc(sdk): Add #4627 in the CHANGELOG.md. 2025-02-05 13:29:08 +01:00
Ivan Enderlin
3e02d90a27 chore(sdk): Remove RoomEventCacheUpdate::Clear.
This patch removes the `Clear` variant of the `RoomEventCacheUpdate`
enum. This one is not needed anymore since we have
`UpdateTimelineEvents` which contains updates as `Vec<VectorDiff<_>>`.
`VectorDiff` _has_ a `Clear` variant. It resulted in a double clear
every time.

This patch updates `RoomEventCacheInner::reset` and
`RoomEventCacheInner::with_events_mut` to annotate them with a
`#[must_use]`. Since they return the updates as `VectorDiff`s,
they **must** be broadcasted/propagated somewhere, likely with
`RoomEventCacheUpdate`. This mechanism ensures to not miss updates.
2025-02-05 13:29:08 +01:00
Ivan Enderlin
954b16ad39 Merge pull request #4603 from zecakeh/media-cache-auto-cleanup
feat(base): Add automatic media cache cleanups to MediaService
2025-02-05 13:24:20 +01:00
Kévin Commaille
ed18c5113f fix: Fix changelogs for new media service feature after new release
Signed-off-by: Kévin Commaille <zecakeh@tedomum.fr>
2025-02-05 00:28:56 +01:00
Kévin Commaille
0f4b3aa187 Merge branch 'main' into media-cache-auto-cleanup 2025-02-05 00:12:18 +01:00
Ivan Enderlin
8a7658745d chore: Fallback to jplatte/eyeball instead of Hywan/eyeball's fork. 2025-02-04 19:43:38 +01:00
Ivan Enderlin
2ea39877cc fix: Add github.com/Hywan/eyeball in the allow-git list. 2025-02-04 19:43:38 +01:00
Ivan Enderlin
4212691cf0 fix(ui): Don't use 0 as the initial value for Skip.
This patch fixes an issue where 0 was used as the initial value for
the `Skip` higher-order stream in the `TimelineSubscriber`. This is
wrong, as the `SkipCount` value may have been modified before the
`TimelineSubscriber` is created.

This patch provides a test to reproduce the problem.
2025-02-04 19:43:38 +01:00
Ivan Enderlin
d66fe79579 task(ui): Create TimelineSubscriber.
This patch gathers the logic of the `Timeline::subscribe` into a single
type: `TimelineSubscriber`.

The `TimelineController::subscribe_batched_and_limited` method is
renamed `subscribe` to match `Timeline::subscribe`. Things are simpler
to apprehend.

The `TimelineSubscriber` type configures the subscriber/stream in a
single place. It takes an `&ObservableItems` and a `&SkipCount`, and
configures everything. It also provides a single place to document the
behaviour of the subscriber, with the `Skip` higher-order stream.
2025-02-04 19:43:38 +01:00
Ivan Enderlin
88caf11842 chore(ui): Rename Timeline::subscribe to subscribe_raw.
This patch renames the (test only) `Timeline::subscribe` method to
`Timeline::subscribe_raw`.
2025-02-04 19:43:38 +01:00
Ivan Enderlin
5320d952e5 test(ui): Test the Timeline lazy backwards pagination. 2025-02-04 19:43:38 +01:00
Ivan Enderlin
7eae832b8c test: set_timeline_prev_batch takes anything that implements Into<String>. 2025-02-04 19:43:38 +01:00
Ivan Enderlin
1d18ab03d7 test(ui): Improve the assert_timeline_stream macro. 2025-02-04 19:43:38 +01:00
Ivan Enderlin
337bc2c097 doc(ui): Fix a typo. 2025-02-04 19:43:38 +01:00