Commit Graph

13223 Commits

Author SHA1 Message Date
Ivan Enderlin ec80c6ff7b feat(ui): Add the recency, name and or sorters for the RoomList.
This patch adds 3 sorters for the `RoomList`: `recency`, `name` and
`or`.
2024-07-03 09:18:23 +02:00
Ivan Enderlin daf878fa7f feat(base): Add LatestEvent::cached_event_origin_server_ts.
This patch adds a new `cached_event_origin_server_ts` field on
`LatestEvent`, which is a copy of the `origin_server_ts` of the inner
`SyncTimelineEvent`.
2024-07-03 09:17:49 +02:00
Ivan Enderlin 7aa7d1ca53 feat(ui): Remove visible_rooms from RoomListService.
This patch removes the `visible_rooms` sliding sync list from
`RoomListService`. As we are taking the path of doing client-side
sorting, the ordering of the server-side will most likely always
mismatch the ordering of the client-side, thus using `visible_rooms`
with room indices make no sense (indices from server-side won't map
indices on the client-side, so room ranges from client-side won't map
what the server knows).

We used to use `visible_rooms` to “preload” the timeline of rooms in
the user app viewport, with a `timeline_limit` of 20. This should be
replaced by room subscriptions starting from now. For the moment, the
user of `RoomListService` is responsible to do that manually. Maybe
`RoomListService` will handle that automatically in the future.
2024-07-03 09:17:28 +02:00
Kegan Dougal 09dc9b913d base: Add trace logging to memory store (#3642)
* Add trace logging to memory store

To help debug https://github.com/matrix-org/complement-crypto/issues/77

* Missing import
* Review comments
2024-07-02 16:20:53 +00:00
Kévin Commaille 0a7184e594 ui: Implement Clone for RepliedToInfo
Signed-off-by: Kévin Commaille <zecakeh@tedomum.fr>
2024-07-02 16:58:48 +02:00
Kévin Commaille 14c8a96f55 ui: Expose identifier or RepliedToInfo and EditInfo
Signed-off-by: Kévin Commaille <zecakeh@tedomum.fr>
2024-07-02 16:58:48 +02:00
Benjamin Bouvier fbeb77ae3e sdk-store-encryption: use ZeroizeOnDrop instead of [zeroize(drop)]
One item of https://github.com/matrix-org/matrix-rust-sdk/issues/3272.
2024-07-02 14:33:19 +02:00
Benjamin Bouvier a1b557b20a ffi(client builder): reduce indent in build_with_qr_code using a let else statement
No functional changes.
2024-07-02 14:05:09 +02:00
Benjamin Bouvier b8fc5f4764 ffi(client builder): inline build_inner into its one caller
No functional changes.
2024-07-02 14:05:09 +02:00
Benjamin Bouvier d531a7cc01 ffi(client builder): inline enable_cross_process_refresh_lock_inner into its one caller
No functional changes.
2024-07-02 14:05:09 +02:00
Benjamin Bouvier 84a57ce690 ffi(client builder): remove unused inner field from the builder 2024-07-02 14:05:09 +02:00
Benjamin Bouvier 263c86b508 send queue: use being_sent as a lock for touching storage
There were two disconnected sources of truth for the state of event to
be sent:

- it can or cannot be in the in-memory `being_sent` map
- it can or cannot be in the database

Unfortunately, this led to subtle race conditions when it comes to
editing/aborting. The following sequence of operations was possible:

- try to send an event: a local echo is added to storage, but it's not
marked as being sent yet
- the task wakes up, finds the local echo in the storage,...
- try to edit/abort the event: the event is not marked as being sent
yet, so we think we can edit/abort it
- ... having found the local echo, it is marked as being sent.

This would result in the event misleadlingly not being aborted/edited,
while it should have been.

Now, there's already a lock on the `being_sent` map, so we can hold onto
it while we're touching storage, making sure that there aren't two
callers trying to manipulate storage *and* `being_sent` at the same
time.

This is pretty tricky to test properly, since this requires super
precise timing control over the state store, so there's no test for
this. I can confirm this avoids some weirdness I observed with
`multiverse` though.
2024-07-01 16:19:48 +02:00
Benjamin Bouvier 2f125e97ee send queue: make SendHandle::abort/update more precise
Using `SendHandle::abort()` after the event has been sent would look
like a successful abort of the event, while it's not the case; this
fixes this by having the state store backends return whether they've
touched an entry in the database.
2024-07-01 16:19:48 +02:00
Benjamin Bouvier 16aa6df0b8 timeline: update test expectation after previous bugfix 2024-07-01 15:44:09 +02:00
Benjamin Bouvier 96422b3c32 send queue: wake up the sending task after editing an event
It could be that the last event in a room's send queue has been marked
as wedged. In that case, the task will sleep until it's notified again.
If the event is being edited, then nothing would wake up the task; a
manual wakeup might be required in that case.

The new integration test shows the issue; the last `assert_update` would
fail with a timeout before this patch.
2024-07-01 15:44:09 +02:00
Damir Jelić eac20766bd fixup! fix(crypto): Rename the device keys property for Olm messages 2024-07-01 15:19:04 +02:00
Damir Jelić 53cdac9661 fix(crypto): Rename the device keys property for Olm messages
Commit d41af396c implemented MSC4147, which puts the device keys into a
Olm message. It failed to adhere to the unstable prefix proposed in the
MSC:

> Until this MSC is accepted, the new property should be named
> org.matrix.msc4147.device_keys.

This patch fixes this.
2024-07-01 15:19:04 +02:00
Andy Balaam 1de3d16d25 Merge pull request #3629 from matrix-org/andybalaam/typos-specific-exceptions
typos: Exclude specific words from typo checking instead of whole files
2024-07-01 14:00:55 +01:00
Andy Balaam 858150b6b6 typos: Exclude specific words from typo checking instead of whole files 2024-07-01 13:40:52 +01:00
Damir Jelić a34e19617a recovery: Ensure that we don't miss updates to the backup state
This patch switches the way we update the recovery state upon changes in
the backup state. Previously two places updated the recovery state after
the backup state changed:

    1. A method living in the recovery subsystem that the backup
       subsystem itself calls.
    2. An event handler which is called when we receive a m.secret.send
       event.

The first method is a hack because it introduces a circular dependency
between the recovery and backup subsystems.

More importantly, the second method can miss updates, because the backup
subsystem has a similar event handler which then processes the secret we
received and if the secret was a backup recovery key, enables backups.

Depending on the order these event handlers are called, the recovery
subsystem might update the recovery state before the secret has been
handled.

The backup subsystem provides an async stream which broadcasts updates
to the backup state, letting the recovery subsystem listen to this
stream and update its state if we notice such updates fixes both
problems we listed above. The method in the first bullet point was
completely removed, the event handler is kept for other secret types but
we don't rely on it for the backup state anymore.
2024-07-01 14:38:26 +02:00
Damir Jelić 9e4164f6f7 encryption: Log when the backup and recovery state changes 2024-07-01 14:38:26 +02:00
Damir Jelić a819dd568d utils: Return the old value in the set method of ChannelObservable 2024-07-01 14:38:26 +02:00
Kévin Commaille 7fee66da11 ui: Rename EventItemIdentifier to TimelineEventItemId
Signed-off-by: Kévin Commaille <zecakeh@tedomum.fr>
2024-07-01 14:32:16 +02:00
Kévin Commaille 9f929f7670 ui: Docs fixes
Signed-off-by: Kévin Commaille <zecakeh@tedomum.fr>
2024-07-01 14:32:16 +02:00
Kévin Commaille b9d0aa9b54 ui: Expose content of RepliedToInfo and EditInfo
Signed-off-by: Kévin Commaille <zecakeh@tedomum.fr>
2024-07-01 14:32:16 +02:00
Kévin Commaille f0867262c7 ui: Get rid of TimelineEventItemId
There is EventItemIdentifier for the same purpose.

Signed-off-by: Kévin Commaille <zecakeh@tedomum.fr>
2024-07-01 14:32:16 +02:00
Benjamin Bouvier 2507a450df send queue: add useful logs when aborting/editing a local echo 2024-07-01 14:12:44 +02:00
Kévin Commaille a7e4849f25 sdk: Use strongly-typed strings where it makes sense
Where a string is clearly documented as a room ID, event ID or mxc URI,
use OwnedRoomId, OwnedEventId and OwnedMxcURI, respectively.

Signed-off-by: Kévin Commaille <zecakeh@tedomum.fr>
2024-07-01 12:55:15 +02:00
Damir Jelić 769fe8bb7d ci: Add a github workflow to fail when fixup commits exist
We tend to use fixup commits quite a bit, and in the heat of the moment
we sometimes forget to squash them before the final merge.

This should prevent us from doing so.
2024-07-01 12:30:02 +02:00
Benjamin Bouvier 52fa00e474 sdk: remove Error::InconsistentState as it was unused 2024-07-01 08:57:09 +02:00
Benjamin Bouvier 17d18321f2 send queue: mark ConcurrentRequestFailed as recoverable
This will still disable the room's send queue, but the embedder may then
decide whether to re-enable the queue or not, based on network
connectivity. Ideally, we'd implement some retry mechanism here too, but
since we're at a different layer than the HTTP one, we can't get that
"for free", so let the embedder decide what to do here.
2024-07-01 08:56:55 +02:00
Kévin Commaille 374da7674e crypto: Remove assert_matches2 from regular dependencies
It was added as a regular dependency in #3517
but it is only used in tests.

Signed-off-by: Kévin Commaille <zecakeh@tedomum.fr>
2024-07-01 08:36:32 +02:00
Ivan Enderlin 1270cdad1a feat(ui): RoomList::entries* manipulates a Room.
This patch is quite big… `RoomList::entries*` now returns `Room`s
instead of `RoomListEntry`s. This patch consequently updates all the
filters to manipulate `Room` instead of `RoomListEntry`. No more
`Client` is needed in the filters.

This patch also disables the `RoomList` integration test suite in order
to keep this patch “small”.
2024-06-30 21:19:27 +02:00
Ivan Enderlin 73b481a8fc chore(cargo): Update eyeball-im and eyeball-im-util.
The idea is to get the `SortBy` stream adapter.
2024-06-30 21:19:25 +02:00
Stefan Ceriu 38a18c3c8e feat(ffi): add Element specific well known struct and a way to deserialize it from external clients 2024-06-28 16:58:55 +02:00
Stefan Ceriu 70fddc0e1b feat(ffi): expose method for reading the server name part of the current user's identifier. 2024-06-28 16:58:55 +02:00
Stefan Ceriu 84796ab32a feat(ffi): expose method for sending generic GET requests through the SDK's inner HTTP client. 2024-06-28 16:58:55 +02:00
Andy Balaam 6464d21813 crypto: Storage changes for keeping sender data with InboundGroupSessions (#3556)
Signed-off-by: Andy Balaam <mail@artificialworlds.net>
Co-authored-by: Damir Jelić <poljar@termina.org.uk>
2024-06-28 14:14:55 +02:00
Hubert Chathi cb4c575234 Reshare Megolm session after the other party unwedges (#3604)
For each recipient device, we keep an "Olm wedging index" that indicates (approximately) how many times they tried to unwedge the Olm session. When we share a Megolm session, we store the Olm wedging index. This allows us to tell whether the Olm session was unwedged since we shared the Megolm session, so that we know if we should re-share it.

We detect an attempt to unwedge the Olm session by checking if the Olm message that we decrypted is from a brand new Olm session. This is not entirely accurate, since this could happen, for example, if Alice and Bob create Olm sessions at the same time. This may result in some Megolm sessions being re-shared unnecessarily, but should not make a huge difference.
2024-06-28 10:08:58 +02:00
Benjamin Bouvier 1c92633a23 ffi: add new error conversions into ClientError
*sigh*
2024-06-27 18:53:00 +02:00
Benjamin Bouvier c3cdc4526e ffi: rename Timeline::edit to Timeline::edit_by_event_id, and introduce a more general Timeline::edit 2024-06-27 18:53:00 +02:00
Benjamin Bouvier 58e2b618b7 timeline: allow editing a local echo too 2024-06-27 18:53:00 +02:00
Benjamin Bouvier e808153473 timeline: react to send queue local echo updates (for room-message events) 2024-06-27 18:53:00 +02:00
Benjamin Bouvier d49190ade4 send queue: allow editing a local echo 2024-06-27 18:53:00 +02:00
Benjamin Bouvier 45c6efcc65 state store: add method to update the content of a send queue event
It also resets the wedged state, so that the queue will retry to send
this event later. This will show useful in the following case: when an
event is too big, we can now retry to send it, even if it was blocked,
by splitting the event instead of copy/abort/recreate it.
2024-06-27 18:53:00 +02:00
Benjamin Bouvier 43d9abae73 base: tweak SerializableEventContent::new signature
The first parameter doesn't need to be taken by ownership, reference is
sufficient.
2024-06-27 18:53:00 +02:00
Benjamin Bouvier 394effbc72 send queue: rename AbortSendHandle to SendHandle 2024-06-27 18:53:00 +02:00
Hubert Chathi d41af396cc Embed device keys in Olm-encrypted messages (#3517)
This patch implements MSC4147[1].

Signed-off-by: Hubert Chathi <hubertc@matrix.org>

[1]: https://github.com/matrix-org/matrix-spec-proposals/pull/4147
2024-06-27 12:18:52 +02:00
Ivan Enderlin 37c125c306 Merge pull request #3615 from Hywan/feat-base-synctimelinevent-constructor
chore(base): Use constructors of `SyncTimelineEvent` to simplify code
2024-06-27 11:11:16 +02:00
Benjamin Bouvier 8e8d793f0d fixup! state store: change schema for send_queue_events table 2024-06-26 19:42:14 +02:00