Commit Graph

202 Commits

Author SHA1 Message Date
Benjamin Bouvier
cf02e694f2 feat(event cache store): add a method to clear all rooms' linked chunks 2024-12-10 12:05:29 +01:00
Benjamin Bouvier
68cb85a2b2 refactor(event cache store): use a single transaction to handle all linked chunk updates at once
Instead of one transaction per update. This ensures that if a single
update fails, then none is taken into account.
2024-12-10 11:32:30 +01:00
Kévin Commaille
d8184e72eb fix(media): Make sure that local MXC URIs only try to get media from the cache and ignore requested dimensions (#4387)
Extracted from #4329. This does not change the `MediaFormat` of the
request used in the media cache by the send queue.

---------

Signed-off-by: Kévin Commaille <zecakeh@tedomum.fr>
2024-12-09 13:43:49 +01:00
Valere
6801811226 feat(crypto): Supports new UtdCause variants for withheld keys
Adds new UtdCause variants for withheld keys, enabling applications to display customised messages when an Unable-To-Decrypt message is expected.

refactor(crypto): Move WithheldCode from crypto to common crate
2024-12-04 15:33:23 +01:00
Damir Jelić
bab979aaf4 chore: Update our changelogs 2024-12-04 11:25:00 +01:00
Benjamin Bouvier
cce322f9c8 test(event cache): add integration test for handling updates and reloading a linked chunk 2024-12-02 14:09:42 +01:00
Benjamin Bouvier
27e1cded2e feat(event cache): reload a linked chunk from a sqlite store 2024-12-02 14:09:42 +01:00
Kévin Commaille
ba5881355d chore(test): Upgrade ctor
Fixes the `unexpected_cfgs` warning so it doesn't need to be disabled anymore.

Signed-off-by: Kévin Commaille <zecakeh@tedomum.fr>
2024-11-29 19:59:24 +01:00
Benjamin Bouvier
daa984f7de feat(event cache store): enable foreign keys pragma \o/ 2024-11-28 11:48:46 +01:00
Benjamin Bouvier
aa0eb760de test(event cache): add a test for reading events from multiple rooms
This was to make sure that we can search by blob.
2024-11-28 11:48:46 +01:00
Benjamin Bouvier
9ed65bc321 task(event cache): address review points 2024-11-28 11:48:46 +01:00
Benjamin Bouvier
ce95b6089f doc(event cache): add the copyright notice and basic module doc comment 2024-11-28 11:48:46 +01:00
Benjamin Bouvier
c6ba71ae33 feat(event cache): allow reloading from the store, and test functionalities
This required adding support for *reading* out of the event cache, for
the sqlite backend. This paves the way for the next PR (reload from the
cache), and it should also help with testing at the `EventCacheStore`
trait layer some day.
2024-11-28 11:48:46 +01:00
Benjamin Bouvier
9bea0cff24 feat(event cache): implement the sqlite backend for events 2024-11-28 11:48:46 +01:00
Damir Jelić
7a454888a3 chore: Bump the deps and move some of them to the workspace 2024-11-27 17:03:50 +01:00
Damir Jelić
a1b7906a7d chore: Fix some clippy lints around lifetimes 2024-11-27 13:23:34 +01:00
Damir Jelić
dcf6af405d chore: Silence unexpected cfg warnings
These are all coming from macro invocations of macros that are defined
in other crates. It's likely a clippy issue. We should try to revert
this the next time we bump the nightly version we're using.
2024-11-27 13:23:34 +01:00
Ivan Enderlin
24b968ad39 refactor: EventCacheStore::handle_linked_chunk_updates takes a Vec<Update>.
This patch updates `EventCacheStore::handle_linked_chunk_updates` to
take a `Vec<Update<Item, Gap>>` instead of `&[Update<Item, Gap>]`.
In fact, `linked_chunk::ObservableUpdates::take()` already returns a
`Vec<Update<Item, Gap>>`; we can simply forward this `Vec` up to here
without any further clones.
2024-11-25 17:08:27 +01:00
Ivan Enderlin
fe52b4cb78 feat(common): EventCacheStore::handle_linked_chunk_updates takes a &RoomId. 2024-11-25 17:08:27 +01:00
Ivan Enderlin
e5ca44bb04 feat(base): Add EventCacheStore::handle_linked_chunk_updates.
This patch adds the `handle_linked_chunk_updates` method on the
`EventCacheStore` trait. Part of
https://github.com/matrix-org/matrix-rust-sdk/issues/3280.
2024-11-20 16:39:49 +01:00
Benjamin Bouvier
0080f17c1f feat(base): add a way to update a dependent send queue request 2024-11-20 10:11:56 +01:00
Benjamin Bouvier
fa47af3dd6 refactor!(base): rename StateStore::update_dependent_queued_request to mark_dependent_queued_requests_as_ready 2024-11-20 10:11:56 +01:00
Benjamin Bouvier
efeac2ef39 fix(base): clear a room's send queue and dependent event queue after removing it from the state store 2024-11-19 16:50:35 +01:00
Damir Jelić
0b16d488ad chore: Release matrix-sdk version 0.8.0 (#4291)
Co-authored-by: Ivan Enderlin <ivan@mnt.io>
2024-11-19 14:11:19 +01:00
Damir Jelić
d40aac89cb fix: Use the DisplayName struct to protect against homoglyph attacks 2024-11-19 11:54:01 +01:00
Benjamin Bouvier
c02d8cee77 feat!(send queue): add a priority field to maintain ordering of sending
Prior to this patch, the send queue would not maintain the ordering of
sending a media *then* a text, because it would push back a dependent
request graduating into a queued request.

The solution implemented here consists in adding a new priority column
to the send queue, defaulting to 0 for existing events, and use higher
priorities for the media uploads, so they're considered before other
requests.

A high priority is also used for aggregation events that are sent late,
so they're sent as soon as possible, before other subsequent events.
2024-11-14 12:00:08 +01:00
Ivan Enderlin
949cd78d94 refactor: Move event_cache_store/ to event_cache/store/ in matrix-sdk-base. 2024-11-13 15:25:58 +01:00
Benjamin Bouvier
1658397139 refactor!(media): rename MediaThumbnailsSetting::new to with_method() 2024-11-07 13:04:10 +01:00
Benjamin Bouvier
77ee02f529 refactor!(media): rename MediaRequest to MediaRequestParameters
Because it's not a request we send to the server; it's some of the
request parameters.
2024-11-06 15:33:51 +01:00
Ivan Enderlin
94c507dd38 test: Testing the cross-process event cache store. 2024-11-06 15:03:50 +01:00
Ivan Enderlin
37304c8cdc refactor: Implement try_take_leased_lock on SqliteEventCacheStore 2024-11-06 15:03:50 +01:00
Ivan Enderlin
e24d9b3ce3 feat(base): Create LockableEventCacheStore. 2024-11-06 15:03:50 +01:00
Benjamin Bouvier
a739ddfc84 chore(event cache store): update test to reflect that previous events and dependent events are cleared
Because the latest migration would clear events to-be-sent from the send
queue, we need to reflect this in this test.
2024-11-04 17:42:47 +01:00
Benjamin Bouvier
1f2e8c5007 refactor!(event cache store): store the serialized QueuedRequestKind, not a raw event
Changelog: The send queue will now store a serialized
 `QueuedRequestKind` instead of a raw event, which breaks the format.
 As a result, all send queues have been emptied.
2024-11-04 17:42:47 +01:00
Benjamin Bouvier
06e6cba156 chore(event cache store): Support multiple parent key types for dependent requests
This makes it possible to have different kinds of *parent key*, to
update a dependent request. A dependent request waits for the parent key
to be set, before it can be acted upon; before, it could only be an
event id, because a dependent request would only wait for an event to be
sent. In a soon future, we're going to support uploading medias as
requests, and some subsequent requests will depend on this, but won't be
able to rely on an event id (since an upload doesn't return an
event/event id).

Since this changes the format of `DependentQueuedRequest`, which is
directly serialized into the state stores, I've also cleared the table,
to not have to migrate the data in there. Dependent requests are
supposed to be transient anyways, so it would be a bug if they were many
of them in the queue.

Since a migration was needed anyways, I've also removed the `rename`
annotations (that supported a previous format) for the
`DependentQueuedRequestKind` enum.
2024-11-04 17:42:47 +01:00
Benjamin Bouvier
be88e0ad69 feat(event cache store): Implement renaming media keys 2024-10-29 18:15:28 +01:00
Benjamin Bouvier
9c858c1208 refactor(base): rename all send-queue related "events" to "requests"
Changelog: Renamed all the send-queue related "events" to "requests", so
  as to generalize usage of the send queue to not-events (e.g. medias,
  redactions, etc.).
2024-10-29 18:15:10 +01:00
Benjamin Bouvier
58d46f015b refactor(base): add a QueuedRequestKind enum
In a next commit, the `QueuedEvent` will be renamed to `QueuedRequest`.
This specifies which kind of request we want to send with the send
queue; for now, it can only be an event.
2024-10-29 18:15:10 +01:00
Benjamin Bouvier
888f992df0 refactor(base): Renamed StateStore::list_dependend_send_queue_events to load_dependent_send_queue_events 2024-10-29 18:15:10 +01:00
Valere
31e9600078 feat(send_queue): Persist failed to send errors (#4137)
Modify the SendQueue in order to persist the error that cause the event
to fail to send as a `QueueWedgeError`. The `QueueWedgeError` is not a
1:1 mapping for all kinds of errors, but holds variant and information
that the client can react to in order to propose "quick fixes"/solution
before retrying to send.

Fixes https://github.com/matrix-org/matrix-rust-sdk/issues/3973 
Also fixes https://github.com/element-hq/element-x-ios/issues/3287
because when a timeline reset occurs the fail to send reason is also
lost.

This PR starts with a refactoring commit
e7696003e8
to introduce the new `QueueWedgedError` and move the logic that was in
the ffi layer to convert api errors to SendState error variant. This
`QueueWedgedError` can be directly use in the `SendingFailed` variant
and expose to ffi.

Second commit
109c133746
adds the persistence, `QueuedEvent` now have an optional error field
instead of a `is_weged` boolean. Same for LocalEchoContent::Event.
Adds also Migration for sqlite and indexeddb

Co-authored-by: Benjamin Bouvier <benjamin@bouvier.cc>

Changelog:  We now persist the error that caused an event to fail to send. The error `QueueWedgeError` contains info that client can use to try to resolve the problem when the error is not automatically retry-able. Some breaking changes occurred in the FFI layer for `timeline::EventSendState`, `SendingFailed` now directly contains the wedge reason enum; use it in place of the removed variant of `EventSendState`.
2024-10-23 12:48:55 +02:00
Damir Jelić
1945b508c3 Create some missing changelog files 2024-10-10 14:32:46 +02:00
Damir Jelić
ca7f2ad3d0 Add a cargo-release config 2024-10-10 14:32:46 +02:00
Kévin Commaille
1e0e815fab base: Remove deprecated StateStore APIs
Signed-off-by: Kévin Commaille <zecakeh@tedomum.fr>
2024-09-30 12:18:10 +02:00
Kévin Commaille
b0e8121347 sqlite: Bump sqlite crates
Signed-off-by: Kévin Commaille <zecakeh@tedomum.fr>
2024-09-04 10:55:38 +02:00
Richard van der Hoff
7bcc920514 sqlite: add get_inbound_group_sessions_for_device_batch 2024-09-02 18:07:38 +01:00
Richard van der Hoff
12653fb2b6 sqlite: add new curve_key and sender_data_type columns 2024-09-02 18:07:38 +01:00
Richard van der Hoff
228a117ccb crypto: add get_inbound_group_sessions_for_device_batch to CryptoStore 2024-09-02 18:07:38 +01:00
Kévin Commaille
7f4e79e2a3 Add link to SQLite docs
Signed-off-by: Kévin Commaille <zecakeh@tedomum.fr>
2024-09-02 17:44:30 +02:00
Kévin Commaille
7807ed8bda sqlite: Update last access time first to force write transaction
Avoids errors when the read transaction tries to upgrade to a write transaction.

Signed-off-by: Kévin Commaille <zecakeh@tedomum.fr>
2024-09-02 17:44:30 +02:00
Benjamin Bouvier
b8d90286aa testing: enforce a test_ prefix for tests
This will only apply to `async_test` functions, but I think this is a
win:

1. for consistency within the codebase, since I've started doing so in
many places,
2. because these function names will clearly identify these functions as
tests, in the call tree interfaces, when rendered using the LSP
show-callers/show-callees functionality.
2024-09-02 12:02:43 +02:00