Commit Graph

626 Commits

Author SHA1 Message Date
Skye Elliot
3924463c6d fix: Correctly store rooms with downloaded keys in SQLite and IndexedDB. (#6044)
While https://github.com/matrix-org/matrix-rust-sdk/pull/6017 is mostly
functional, there are two issues:

- I did not process `changes.room_key_bundles_fully_downloaded` in
`matrix-sdk-sqlite`, meaning any updates made via `Changes` would not be
persisted;
- I used a non-encrypting `JsValue` serialisation for the same field in
`matrix-sdk-indexeddb`, which causes errors when passed to the
decryption-enabled deserializer.

Solutions:

- Process the aforementioned changes such that keys are added to SQLite;
- Use a non-encrypting deserialiser, since this is effectively a
hash-set, and the contents aren't sensitive.

Signed-off-by: Skye Elliot <actuallyori@gmail.com>
2026-01-26 14:12:54 +00:00
Skye Elliot
90390d7488 Merge pull request #6017 from matrix-org/kaylendog/history-sharing/backup-download
feat: Download room keys from backup before building key bundle.
2026-01-16 17:03:46 +00:00
Benjamin Bouvier
5b8ff8a76d refactor(state store): remove StateStore::upsert_thread_subscription
There is `StateStore::upsert_thread_subscriptions` as a proper
replacement these days.
2026-01-16 17:01:03 +01:00
Skye Elliot
3baaef5109 feat: Download room keys from backup before building key bundle.
Signed-off-by: Skye Elliot <actuallyori@gmail.com>
2026-01-13 15:19:28 +00:00
Jonas Platte
ebbf34e924 Fix more new clippy lints 2026-01-06 09:51:10 +00:00
Jonas Platte
e4aff871de Refactor IndexeddbStateStore::save_changes 2026-01-06 09:51:10 +00:00
Jonas Platte
0a9994c529 Fix new clippy lints 2026-01-06 09:51:10 +00:00
Jonas Platte
06764e2542 Reformat matrix-sdk-indexeddb 2026-01-06 09:51:10 +00:00
Skye Elliot
b3f6df939b Merge pull request #5943 from matrix-org/kaylendog/history_sharing/store_history_sender_details
feat(crypto): Add `forwarder_data` to `InboundGroupSession` and pickle.
2025-12-17 17:16:57 +00:00
Richard van der Hoff
f753d478fa feat: Add forwarder_data to InboundGroupSession and pickle.
- Introduces `forwarder_data` to IGS and its pickled form, and a
  helper method to import them from `HistoricRoomKey`s.

Issue: https://github.com/matrix-org/matrix-rust-sdk/issues/5109

Signed-off-by: Skye Elliot <actuallyori@gmail.com>
2025-12-17 12:33:16 +00:00
Michael Goldenberg
8e1510821b style(indexeddb): cargo fmt
Signed-off-by: Michael Goldenberg <m@mgoldenberg.net>
2025-12-17 12:56:09 +01:00
Michael Goldenberg
288f28620c refactor(indexeddb): add deprecation note on open_stores_with_name()
Signed-off-by: Michael Goldenberg <m@mgoldenberg.net>
2025-12-17 12:56:09 +01:00
Michael Goldenberg
6bf121b58e refactor(indexeddb): ensure event-cache-store feature flag compiles in isolation
Signed-off-by: Michael Goldenberg <m@mgoldenberg.net>
2025-12-17 12:56:09 +01:00
Michael Goldenberg
01b130a401 refactor(indexeddb): ensure media-store feature flag compiles in isolation
Signed-off-by: Michael Goldenberg <m@mgoldenberg.net>
2025-12-17 12:56:09 +01:00
Michael Goldenberg
256fb0406d refactor(indexeddb): use finer-grain feature flags to include/exclude serializers
Signed-off-by: Michael Goldenberg <m@mgoldenberg.net>
2025-12-17 12:56:09 +01:00
Michael Goldenberg
e74bf33178 feat(indexeddb): expose struct and fns for opening all stores
Signed-off-by: Michael Goldenberg <m@mgoldenberg.net>
2025-12-17 12:56:09 +01:00
Michael Goldenberg
2bec882c83 feat(indexeddb): add fn to media store builder for prefixing db name
Signed-off-by: Michael Goldenberg <m@mgoldenberg.net>
2025-12-17 12:56:09 +01:00
Michael Goldenberg
2cfcc957ca feat(indexeddb): add fn to event cache store builder for prefixing db name
Signed-off-by: Michael Goldenberg <m@mgoldenberg.net>
2025-12-17 12:56:09 +01:00
razvp
67b1de613c feat(state-stores): Add StateStore::upsert_thread_subscriptions() method for bulk upsert 2025-12-17 11:03:50 +01:00
Michael Goldenberg
790136b9db fix(indexeddb): skip encoding event id when constructing bounds
In the implementation of EventCacheStore, there are a number of
places where the upper and lower bounds of an EventId are
constructed. It is important to bypass hashing and encryption
when constructing these bounds, otherwise the values will be
modified and will no longer represent the bounds.

Signed-off-by: Michael Goldenberg <m@mgoldenberg.net>
2025-12-09 15:24:15 +01:00
Michael Goldenberg
265cfc7710 test(indexeddb): initialize store cipher in encrypted tests for event cache and media store
Note that the encrypted tests were actually being run unencrypted.
Introducing a store cipher causes them to run encrypted, and
furthermore, reveals some bugs which are only visible when running
an encrypted event cache store.

Signed-off-by: Michael Goldenberg <m@mgoldenberg.net>
2025-12-09 15:24:15 +01:00
Jorge Martín
bc45457d0e feat: add Client::get_store_sizes
This method will retrieve the database sizes if available and expose it in the client.

Note: the actual database size measuring is only implemented for the SQLite based stores
2025-12-03 15:41:42 +01:00
Jorge Martín
e1cda064ee refactor: hopefully fix another lint error 2025-12-03 15:41:42 +01:00
Jorge Martín
94e5dbea0c refactor: hide optimize_store methods, add warnings to not use them in production
Also fix lint issue
2025-12-03 15:41:42 +01:00
Jorge Martín
b04cc9fe27 feat: Implement the new Store::optimize method added in the store traits
Only SQLite based stores will implement it for now, calling the `SqliteAsyncConnExt::vacuum` method
2025-12-03 15:41:42 +01:00
Ivan Enderlin
b4d7881a58 chore: Reduce the number of logs.
This patch removes some logs around the cross-process lock methods. This
is called pretty often by the cross-process lock task, which pollute the
log files.
2025-12-02 21:59:46 +01:00
Kévin Commaille
e47867f232 refactor(sdk): Split supported versions and well-known cache
The supported versions are necessary for querying almost all endpoints,
but after homeserver auto-discovery the well-known info is only
necessary to get the MatrixRTC foci advertised by the homeserver. So it
shouldn't be necessary to always request both at the same time.

Besides:

- Not all clients support MatrixRTC, so they don't need the well-known
  info.
- The well-known info is only supposed to be used for homeserver
  auto-discovery before login. In fact, the MatrixRTC MSC was changed to
  use a new endpoint for this.
- We don't have access to the server name after restoring the Client, so
  the well-known lookup is more likely to fail.

Signed-off-by: Kévin Commaille <zecakeh@tedomum.fr>
2025-12-01 15:22:48 +00:00
Kévin Commaille
4411274b12 refactor(base): Split TTL store logic from ServerInfo into new type
To make it reusable.

Signed-off-by: Kévin Commaille <zecakeh@tedomum.fr>
2025-12-01 15:22:48 +00:00
Ivan Enderlin
f7a767ce97 feat(indexeddb): Add Lease::generation in crypto, media, and event cache stores.
This patch adds `Lease::generation` support in the crypto, media and
event cache stores.

For the crypto store, we add the new `lease_locks` object store/table.
Previously, `Lease` was stored in `core`, but without any prefix, it's
easy to overwrite another records, it's dangerous. The sad thing is
that it's hard to delete the existing leases in `core` because the keys
aren't known. See the comment in the code explaining the tradeoff.

For media and event cache stores, the already existing `leases` object
store/table is cleared so that we can change the format of `Lease`
easily.
2025-11-07 11:26:09 +01:00
Ivan Enderlin
01d75e939c chore(indexeddb): Run rustfmt. 2025-11-07 11:26:09 +01:00
Damir Jelić
49db60d951 feat: Allow events to be fetched by event type 2025-11-04 13:58:49 +01:00
Richard van der Hoff
444fcfa098 stores: new method CryptoStore::get_withheld_sessions_by_room_id
Implement this across all the store implementations
2025-10-30 23:10:05 +00:00
Richard van der Hoff
8189010d58 indexeddb: invert key order for withheld sessions
... in preparation for extracting all withheld sessions for a given room.
2025-10-30 18:50:24 +00:00
Michael Goldenberg
155a7b481b refactor(indexeddb): use UUID instead of u64 as media content id
Signed-off-by: Michael Goldenberg <m@mgoldenberg.net>
2025-10-27 16:59:00 +01:00
Michael Goldenberg
0ac943b4c4 refactor(indexeddb): rename MediaContent::id -> MediaContent::content_id
Signed-off-by: Michael Goldenberg <m@mgoldenberg.net>
2025-10-27 16:59:00 +01:00
Michael Goldenberg
18fe2b20e6 doc(indexeddb): fix typos in documentation
Signed-off-by: Michael Goldenberg <m@mgoldenberg.net>
2025-10-27 16:59:00 +01:00
Michael Goldenberg
64a0f62631 refactor(indexeddb): remove (de)serialization functionality from top-level media type
Signed-off-by: Michael Goldenberg <m@mgoldenberg.net>
2025-10-27 16:59:00 +01:00
Michael Goldenberg
c169cab3b0 refactor(indexeddb): remove media object store and associated types
Signed-off-by: Michael Goldenberg <m@mgoldenberg.net>
2025-10-27 16:59:00 +01:00
Michael Goldenberg
91858e0913 refactor(indexeddb): simplify error type for media metadata impl of indexed
Signed-off-by: Michael Goldenberg <m@mgoldenberg.net>
2025-10-27 16:59:00 +01:00
Michael Goldenberg
f70c036ff9 refactor(indexeddb): re-implement media-related fns in terms of media metadata and media content stores
Signed-off-by: Michael Goldenberg <m@mgoldenberg.net>
2025-10-27 16:59:00 +01:00
Michael Goldenberg
70d6d557ca refactor(indexeddb): implement specialized fn for getting media metadata keys via generalized fn
Signed-off-by: Michael Goldenberg <m@mgoldenberg.net>
2025-10-27 16:59:00 +01:00
Michael Goldenberg
a52df18740 refactor(indexeddb): add transaction fns for getting media metadata keys by index
Signed-off-by: Michael Goldenberg <m@mgoldenberg.net>
2025-10-27 16:59:00 +01:00
Michael Goldenberg
ce6ef90f74 refactor(indexeddb): rename transaction fn for getting all media metadata keys
Signed-off-by: Michael Goldenberg <m@mgoldenberg.net>
2025-10-27 16:59:00 +01:00
Michael Goldenberg
5f00e71f5f refactor(indexeddb): add content id to media metadata keys
Signed-off-by: Michael Goldenberg <m@mgoldenberg.net>
2025-10-27 16:59:00 +01:00
Michael Goldenberg
539bd9c79a refactor(indexeddb): add constants for media content id bounds
Signed-off-by: Michael Goldenberg <m@mgoldenberg.net>
2025-10-27 16:59:00 +01:00
Michael Goldenberg
23785a3023 refactor(indexeddb): remove unused type synonym
Signed-off-by: Michael Goldenberg <m@mgoldenberg.net>
2025-10-27 16:59:00 +01:00
Michael Goldenberg
3d31b81abf refactor(indexeddb): add type synonym for content id in indexed media content key
Signed-off-by: Michael Goldenberg <m@mgoldenberg.net>
2025-10-27 16:59:00 +01:00
Michael Goldenberg
3b2ef02749 refactor(indexeddb): add fn for prefixed key ranges from existing key ranges
Signed-off-by: Michael Goldenberg <m@mgoldenberg.net>
2025-10-27 16:59:00 +01:00
Michael Goldenberg
c887819809 refactor(indexeddb): return indexed type from Transaction::{put_item,put_item_if} and its derivatives
Signed-off-by: Michael Goldenberg <m@mgoldenberg.net>
2025-10-27 16:59:00 +01:00
Michael Goldenberg
780b782660 refactor(indexeddb): return indexed type from Transaction::add_item and its derivatives
Signed-off-by: Michael Goldenberg <m@mgoldenberg.net>
2025-10-27 16:59:00 +01:00