Commit Graph

9110 Commits

Author SHA1 Message Date
Richard van der Hoff
885b2b22bd indexeddb: Revert change from into_serde to serde_wasm_bindgen::from_value
Turns out that `serde_wasm_bindgen` isn't happy with some input. Haven't
figured out why, yet.
2024-07-03 17:59:37 +01:00
Richard van der Hoff
09d53a52ad indexeddb: changelog 2024-07-03 14:10:35 +01:00
Richard van der Hoff
6d46e35d50 indexeddb: Make serialize_value a wrapper for maybe_encrypt_value
... and make `deserialize_value` handle both the old and new formats.

`maybe_encrypt_value` uses a much more efficient representation, so let's
migrate to that.
2024-07-03 14:10:29 +01:00
Richard van der Hoff
87653da2e3 indexeddb: Inline a call to IndexeddbSerializer::serialize_value
I'm going to change the behaviour of `serialize_value`, and we want to preserve
the behaviour of this test.
2024-07-03 14:10:29 +01:00
Richard van der Hoff
a38eaf08be indexeddb: Add some tests for IndexeddbSerializer 2024-07-03 14:10:16 +01:00
Richard van der Hoff
786015f18c indexeddb: Make maybe_en/decrypt_value generic 2024-07-03 14:10:10 +01:00
Kévin Commaille
a2235d50c1 crypto: Decrypt events bundled in unsigned object of another event
Signed-off-by: Kévin Commaille <zecakeh@tedomum.fr>
2024-06-19 17:40:49 +02:00
Ivan Enderlin
0cd93a2f06 Merge pull request #3578 from Hywan/fix-sdk-linked-chunk-substract-overflow
fix(sdk): Fix a substract with overflow in `LinkedChunk`
2024-06-19 14:05:08 +02:00
Ivan Enderlin
edcd573b6f fix(sdk): Fix a substract with overflow in LinkedChunk. 2024-06-19 12:17:23 +02:00
Damir Jelić
a6c962b9b0 chore: Fix the compilation of the benchmarks outside of the workspace root
The workspace root enables some features which are required to compile
the benchmarks, but if you decide to just compile the benchmarks these
features won't be enabled since they aren't specified in the Cargo.toml
file of the benchmarks.

Let's define all the required features so compilation works in both
cases.
2024-06-19 12:06:53 +02:00
Mauro
306a9f7d3b Allow edit and reply to work also for events that have not yet been paginated (#3553)
Fixes #3538 

The current implementation for send_reply and edit only work with timeline items that have already been paginated.
However given the fact that by restoring drafts, we may restore a reply to an event for timeline where such event has not been paginated, sending such reply would fail (same for the edit event).

So I reworked a bit the code here to use. only the event id, and reuse the existing timeline if available, otherwise we can fetch the event and synthethise the content and still be able to successfully send the event.

This is the third part of the breakdown of the following PR: https://github.com/matrix-org/matrix-rust-sdk/pull/3439
2024-06-19 11:58:57 +02:00
dependabot[bot]
2834fa135a build(deps): bump curve25519-dalek from 4.1.2 to 4.1.3
Bumps [curve25519-dalek](https://github.com/dalek-cryptography/curve25519-dalek) from 4.1.2 to 4.1.3.
- [Release notes](https://github.com/dalek-cryptography/curve25519-dalek/releases)
- [Commits](https://github.com/dalek-cryptography/curve25519-dalek/compare/curve25519-4.1.2...curve25519-4.1.3)

---
updated-dependencies:
- dependency-name: curve25519-dalek
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
2024-06-19 11:41:05 +02:00
Richard van der Hoff
4822057163 sdk: Fix key backup download for ratcheted sessions (#3568)
Fixes https://github.com/matrix-org/matrix-rust-sdk/issues/3446 by checking
that we have the key for the event in question, not just the key for the
session.
2024-06-19 09:40:19 +01:00
Ivan Enderlin
6340eeac0b Merge pull request #3068 from Hywan/feat-roomlist-sorting
feat(base): Implement `Client::rooms_stream`
2024-06-19 08:27:37 +02:00
Ivan Enderlin
717c68d9b4 test(sdk): Test Client::rooms_stream.
This patch adds an integration test for `Client::rooms_stream`.
2024-06-18 17:37:08 +02:00
Ivan Enderlin
1e639c431f doc(base): Improve documentation. 2024-06-18 17:37:07 +02:00
Ivan Enderlin
dd2ef57d37 feat(base): Extract ObservableMap into its own module. 2024-06-18 17:37:07 +02:00
Richard van der Hoff
565f97409e sdk: Rewrite BackupDownloadTask
Change this so that it fires off a task for each UTD event, rather than each
megolm session. This is a step towards considering the message index when
deciding whether to carry on with the download.
2024-06-18 14:17:36 +01:00
Richard van der Hoff
792402eca2 sdk: Expose WeakClient::strong_count
... allowing you to see if the client is alive without the overhead of
constructng a ref to the client.
2024-06-18 14:17:36 +01:00
Richard van der Hoff
53e3a7c242 sdk: BackupDownloadTask: use a new struct for the mpsc queue
We'll need to add more data here soon.
2024-06-18 14:17:36 +01:00
Richard van der Hoff
dc2111f156 sdk: Push deserialization of UTD events down to BackupDownloadTask
This means the higher-level classes can be agnostic about the encryption
algorithm; we don't actually care about that until BackupDownloadTask.
2024-06-18 14:17:36 +01:00
Richard van der Hoff
f1802d9bbe sdk: update Backups::utd_event_handler api
Make it take a `Raw<OriginalSyncRoomEncryptedEvent>`, to be consistent with
`Room::decrypt_event`.
2024-06-18 14:17:36 +01:00
Richard van der Hoff
2b5d2e97c0 sdk: add documentation on Backups::utd_event_handler 2024-06-18 14:17:36 +01:00
Benjamin Bouvier
0b9daa2702 timeline: when deduplicating event meta, keep the most recent instead of the oldest
Not doing this leads to an invalid ordering of events, as shown in the
test: if we increase the timeline limit of a room using sliding sync,
we'll receive a duplicate event, and if we ignore it, it'll be in an
invalid position. The solution is to keep the most recent event (and
remove the old one from event_meta).
matrix-sdk-ffi/20240618
2024-06-18 14:39:27 +02:00
Doug
304350ffd4 ffi: Expose room heroes (adding support for avatars). (#3503)
This PR makes 2 changes:
- Updates the storage of room heroes to be a single array containing the user's complete profile.
- Exposes these to the FFI so that client apps can use these for avatar colours/clusters.

Closes #2702 (again, now with avatars 🖼️)

---

* rooms: Store heroes as a complete user profile.

* ffi: Expose room heroes on Room and RoomInfo.

* chore: Remove TODO comment.

* Update crates/matrix-sdk-base/src/rooms/normal.rs

Signed-off-by: Benjamin Bouvier <public@benj.me>

---------

Signed-off-by: Benjamin Bouvier <public@benj.me>
Co-authored-by: Benjamin Bouvier <public@benj.me>
2024-06-18 10:10:09 +00:00
Benjamin Bouvier
8988094df5 sdk: introduce RetryKind next to the HttpError to determine errors that should be retried
retry kind: make `characterize_retry_kind` a method of `HttpError`

---

retry kind: mark all network errors as transient

This should cause more backoff in general, if the client is disconnected
of the grid, or the remote server is, which is good behavior to have in
general.

---

http error: introduce another rustfmt-formated impl block for HttpError

The previous `impl` block was marked as skipping rustfmt, which led to
weird formatting behavior.

Changes are formatting only.
2024-06-17 17:15:07 +02:00
Benjamin Bouvier
f93df8cb9e send queue: improve testing with a lil macro 2024-06-17 17:15:07 +02:00
Benjamin Bouvier
ced8c4c821 send queue: add a test that simulates unreachable network/server 2024-06-17 17:15:07 +02:00
Benjamin Bouvier
f45098a61d send queue: flag unrecoverable errors, and don't block the queue on those 2024-06-17 17:15:07 +02:00
Richard van der Hoff
d146ba869a sdk: Refactor key-backup integration tests (#3560)
* sdk: Integ tests: factor out some helper methods

A few common methods for logic shared between the tests. This serves two
purposes:

 * It reduces duplication, this making it easier to maintain the tests by
   reducing the number of places that we have to change things.

 * It makes the tests easier to read. By factoring out discrete steps, it's
   much easier to get an overview of what a test is doing than when it's all in
   one big function.

* sdk: Integ tests: timeout if nothing happens

If the test is going to fail, let's have it do so properly rather than
mysteriously getting stuck.
2024-06-17 15:42:48 +01:00
Ivan Enderlin
01d6a9e7b7 chore(base): Make Clippy happy. 2024-06-17 15:16:09 +02:00
Ivan Enderlin
e9121ab1ff feat(base): Create an ObservableMap for wasm32-unknown-unknown.
This patch creates an `ObservableMap` for `wasm32-unknown-unknown` which
simply wraps a `BTreeMap`, and without the `stream` method. Indeed, the
first implementation uses `eyeball_im::ObservableVector` which requires
`Send` and `Sync` on its values, which cannot compile to Wasm.
2024-06-17 15:16:07 +02:00
Ivan Enderlin
6e7f53dc19 feat(sdk): Implement Client::rooms_stream.
This patch implements `Client::rooms_stream` by forwarding the
result of `matrix_sdk_base::Client::rooms_stream`, and mapping the
`matrix_sdk_base::Room` to `matrix_sdk::Room`.
2024-06-17 15:15:43 +02:00
Ivan Enderlin
e028710cf9 test: Fix a compiler warning if e2e-encryption and experimental-sliding-sync aren't enabled. 2024-06-17 14:46:45 +02:00
Ivan Enderlin
f9e8f1178b feat(base): Implement Client::rooms_stream.
This patch implements `Client::rooms_stream`, which forwards the result
of the recently added `Store::rooms_stream` method.
2024-06-17 14:46:45 +02:00
Ivan Enderlin
fd4505b026 fix(base): Define matrix_sdk_base::latest_event also if e2e-encryption is enabled.
Running `cargo test -p matrix-sdk-base --features e2e-encryption`
makes the code to fail to compile because `crate::latest_event` isn't
defined. And indeed, it must be defined if `experimental-sliding-sync`
is enabled, but also if `e2e-encryption` is enabled.
2024-06-17 14:46:45 +02:00
Ivan Enderlin
11bced4876 feat(base): Implement Store::rooms_stream.
This patch implements a new `Store::rooms_stream` method that forwards
the result of `ObservableMap::stream`.
2024-06-17 14:46:44 +02:00
Ivan Enderlin
6dac77fd5e feat(base): Implement ObservableMap::stream.
This patch basically implements `ObservableMap::stream` which returns a
batched stream of the values.
2024-06-17 14:46:44 +02:00
Ivan Enderlin
a67e7f2795 feat(base): Rename Rooms to generic ObservableMap + add tests.
This patch rewrites `Rooms` to a generic `ObservableMap` struct. It also
adds documentation and tests for this type.
2024-06-17 14:46:44 +02:00
Ivan Enderlin
5870dafe2e feat(base): Make Store::rooms observable.
This patch updates `Store::rooms` from a
`Arc<StdRwLock<BTreeMap<OwnedRoomId, Room>>>` to a
`Arc<StdRwLock<Rooms>>` where `Rooms` is a new type that mimics a
`BTreeMap` but that is observable. It uses an `ObservableVector`
for saving us the costs of writing a new `ObservableMap` type in
`eyeball-im`. It would have too much implications that are clearly
not necessary. The major one being that an `ObservableMap` must emit
`MapDiff`, but we expect `VectorDiff` everywhere in the SDK where rooms
are observable. It would break too many API and too many projects.

The benchmark is coming, but here are the results (for 10'000 rooms,
extreme case):

* `get_rooms` and `get_rooms_filtered` are twice faster (in practise, it
  means 650µs is saved per call),
* `get_room` and `get_or_create_room` are 10% slower (in practise, it
  means 8-10ns is lost per call).

Overall, I believe these results are acceptable, and even an improvement
for the first one.
2024-06-17 14:46:44 +02:00
Ivan Enderlin
3ffeef55a6 Merge pull request #3561 from Hywan/fix-base-box-stream
chore(base): Remove `BoxStream` as it's never used
2024-06-17 14:46:09 +02:00
Timo
cb7814b362 MatrixRTC: bump ruma to be compatible with MSC4143.
Adapt types for the new ruma version.
2024-06-17 14:21:22 +02:00
Ivan Enderlin
2ecd54a3b2 chore(base): Remove BoxStream as it's never used.
This patch removes the public type alias `BoxedStream` which is never
used in our code.
2024-06-17 13:08:59 +02:00
Ivan Enderlin
b34a2cdfc9 Merge pull request #3559 from matrix-org/feat-sdk-sliding-sync-get-room-id
chore(sdk): Remove the useless `SlidingSyncList::get_room_id` method
2024-06-17 13:02:28 +02:00
Ivan Enderlin
304c225c8f chore(sdk): Remove the useless SlidingSyncList::get_room_id method.
This patch removes the useless `SlidingSyncList::get_room_id` method as
I don't see how it can be useful for anybody. It's mostly dead public
code, let's clean that up.
2024-06-17 12:13:26 +02:00
Benjamin Bouvier
72adaf4119 sdk: slightly better doc for HttpError 2024-06-17 10:50:06 +02:00
Benjamin Bouvier
c656ad4068 sdk: prefer direct use of IntoHttp ctor instead of implicit #[from] conversions 2024-06-17 10:50:06 +02:00
Benjamin Bouvier
c33a7b77e1 sdk: prefer direct use of RefreshToken ctor instead of implicit #[from] conversions
This might be controversial, but I do strongly prefer explicit over
implicit, in this case: it helps looking at the use cases, when using
the LSP's goto_references().
2024-06-17 10:50:06 +02:00
Benjamin Bouvier
7f64580ce2 sdk: use Error::AuthenticationRequired instead of HttpError::AuthenticationRequired
The HttpError variant was misplaced, as it was always used when the
`user_id()` is missing, which is causing `Error::AuthenticationRequired`
errors everywhere else in the code base. This patch streamlines usage of
`Error::AuthenticationRequired`, and gets rid of the `HttpError`
variant.
2024-06-17 10:50:06 +02:00
Benjamin Bouvier
08d7bd0cee sdk: get rid of the UnableToCloneRequest error which is absolutely unused 2024-06-17 10:50:06 +02:00