Commit Graph

5941 Commits

Author SHA1 Message Date
Ivan Enderlin
ddc8d915cb doc(sdk): Fix syntax error. 2023-05-17 16:34:12 +02:00
Ivan Enderlin
f8e12f6aaf doc(sdk): Update documentation according to last commits. 2023-05-17 15:42:30 +02:00
Ivan Enderlin
63feec1433 test(sdk): Test impl From<SlidingSyncMode> for …RequestGenerator`. 2023-05-17 15:32:35 +02:00
Ivan Enderlin
1a60983e8f feat(ffi): Add SlidingSyncListBuilder::sync_mode_*.
This patch replaces `sync_mode` on `SlidingSyncListBuilder` by
`sync_mode_selective`, `sync_mode_paging` and `sync_mode_growing`, which
removes the need to use `SlidingSyncMode` directly.

This patch also removes `batch_size`, `room_limit` and `no_room_limit`
as it's now arguments of `sync_mode_paging` and `sync_mode_growing`.
2023-05-17 15:18:51 +02:00
Ivan Enderlin
41c09a5ec5 feat(sdk): SlidingSyncMode has richer variants.
`SlidingSyncMode` was previously declared as:

```rust
enum SlidingSyncMode {
    Selective,
    Paging,
    Growing,
}
```

Now, the new declaration is:

```rust
enum SlidingSyncMode {
    Selective,
    Paging {
        batch_size: u32,
        maximum_number_of_rooms_to_fetch: Option<u32>,
    },
    Growing {
        batch_size: u32,
        maximum_number_of_rooms_to_fetch: Option<u32>,
    }
}
```

First off, it helps to remove the `full_sync_batch_size` and
`full_sync_maximum_number_of_rooms_to_fetch` methods and fields from
`SlidingSyncListBuilder`. It was containing default values in case of.
That was useless and needed to be fixed. Also, calling a `full_sync_*`
method with the `Selective` mode had no effect, which could disturb
the user. Well, now everything is clean on that front.

Second, `SlidingSyncListRequestGenerator` no longer has constructors,
but a `From<SlidingSyncMode>` implementation. However, the constructors
now live in `SlidingSyncMode` with `new_selective`, `new_paging` and
`new_growing` methods which are helpers. All in all, it makes creating a
`SlidingSyncListRequestGeneator` simpler: just call `sync_mode.into()`
and boom.

Finally, this patch removes the `default_with_fullsync` list builder
helper, which makes no sense at all.
2023-05-17 14:49:55 +02:00
Ivan Enderlin
63257e6226 fix(sdk): Remove room unsubscriptions once the server has received them
fix(sdk): Remove room unsubscriptions once the server has received them
2023-05-17 11:59:16 +02:00
Damir Jelić
1510576ce1 Expose the git description and commit hash in the crypto-ffi bindings
Co-authored-by: Jonas Platte <jplatte@matrix.org>
2023-05-17 09:31:52 +00:00
Ivan Enderlin
501b990248 chore(sdk): Rename SlidingSync::unsubscribe_to_room to …_from_room. 2023-05-17 11:29:26 +02:00
Valere
405db06495 refactor(crypto): get_or_load never returns crypto error 2023-05-17 09:20:37 +00:00
Jonas Platte
be7e162ce1 Restore timeline integration tests
The directory had the wrong name, so it wasn't detected by Cargo.
2023-05-17 11:14:16 +02:00
Ivan Enderlin
b7374a78e9 doc(sdk): Update documentation for SlidingSync::(un)subscribe_to_room. 2023-05-17 11:10:03 +02:00
Ivan Enderlin
d8a9408efe fix(sdk): Remove room unsubscriptions once the server has received them.
This bug has been found by @bnjbvr, all the credits go to him. I've just
added some comments around his code.

Prior to this patch, the room unsubscription buffer
(`SlidingSync::room_unsubscriptions`) was reset before the request was
sent. So if something went wrong, the next request would not include the
room unsubscriptions.

This patch updates this behavior. First, it replaces `Vec` by `HashSet`
to avoid a O(n^2) look up.

Second, a copy of room unsubscriptions used by the request is kept, so
that it can be used to cherry-pick which room unsubscription to remove
from the buffer once a response from the server is received. It's
important to not clear the entire room unsubscriptions buffer as more
unsubscriptions could have been inserted meanwhile.
2023-05-17 10:14:34 +02:00
Ivan Enderlin
9b7122768f chore(sdk): Rename SlidingSync room subscriptions and unsubscriptions API.
Notably, this patch renames `SlidingSync::subscribe` and `::unsubscribe`
to `subscribe_to_room` and `unsubscribe_to_room`.
2023-05-17 10:01:55 +02:00
Jonas Platte
5fa2fff8e5 ui: Re-export TLS features 2023-05-17 09:58:31 +02:00
Jonas Platte
31e32c307f ui: Add missing copyright headers 2023-05-17 09:58:31 +02:00
Jonas Platte
d620f83e0d Enable syntax highlighting in sliding_sync README 2023-05-17 09:58:31 +02:00
Jonas Platte
cfc8effa66 Move timeline API into a new crate
… aimed at interactive user interfaces.
2023-05-17 09:58:31 +02:00
Jonas Platte
91d97cd588 sdk: Re-export matrix_sdk_base::crypto 2023-05-17 09:58:31 +02:00
Jonas Platte
910022bca6 sdk: Make useful push related methods public 2023-05-17 09:58:31 +02:00
Jonas Platte
a6fe0bb34d sdk: Merge identical ensure_members, sync_members methods 2023-05-17 09:58:31 +02:00
Damir Jelić
0144826884 crypto: Log if and which fallback key got removed 2023-05-16 16:25:20 +02:00
Damir Jelić
35a0f3af25 crypto: Improve some logs around Olm decryption and encryption 2023-05-16 16:25:20 +02:00
Damir Jelić
9f1ec9ac3a crypto: Log the result of one-time key generation 2023-05-16 16:25:20 +02:00
Jonas Platte
c796302a98 ffi: Fix typo in variant name 2023-05-16 11:32:15 +02:00
Richard van der Hoff
1c8d2a1225 Merge pull request #1923 from matrix-org/release-matrix-sdk-crypto-js-0.1.0-alpha.9
matrix-sdk-crypto-js v0.1.0-alpha.9
2023-05-15 19:50:53 +01:00
Ivan Enderlin
df8242a23e test(sdk): New Sliding Sync integration test suite for a mocked server
test(sdk): New Sliding Sync integration test suite for a mocked server
2023-05-15 20:30:23 +02:00
Ivan Enderlin
5b55145a1c Merge branch 'main' into test-sliding-sync-room-timeline 2023-05-15 20:06:42 +02:00
Ivan Enderlin
d24a3922a0 test(sdk): Avoid ambiguity in pos. 2023-05-15 20:03:02 +02:00
Richard van der Hoff
6c0afae0f4 Merge remote-tracking branch 'origin/main' into release-matrix-sdk-crypto-js-0.1.0-alpha.9 matrix-sdk-crypto-js-0.1.0-alpha.9 2023-05-15 18:59:52 +01:00
Richard van der Hoff
923d425585 crypto-js: expose a constructor for SigningKeysUploadRequest (#1925)
... to help with testing.
2023-05-15 18:58:38 +01:00
Richard van der Hoff
89bf7f27f3 fix typo 2023-05-15 18:42:58 +01:00
Benjamin Bouvier
58dbe1e252 feat: add add_cached_list to SlidingSyncBuilder and SlidingSync (#1876)
This has slightly drifted from the initial design I thought about in the issue.

Instead of having `build()` be fallible and mutably borrow some substate (namely `BTreeMap<OwnedRoomId, SlidingSyncRoom>`) from `SlidingSync` (that may or may not already exist), I've introduced a new `add_cached_list` method on `SlidingSync` and `SlidingSyncBuilder`. This method hides all the underlying machinery, and injects the room data read from the list cache into the sliding sync room map.

In particular, with these changes:

- any list added with `add_list` **won't** be loaded from/written to the cache storage,
- any list added with `add_cached_list` will be cached, and an attempt to reload it from the cache will be done during this call (hence `async` + `Result`).
- `SlidingSyncBuilder::build()` now only fetches the `SlidingSync` data from the cache (assuming the storage key has been defined), not that of the lists anymore.

Fixes #1737.

Signed-off-by: Benjamin Bouvier <public@benj.me>
Co-authored-by: Jonas Platte <jplatte+git@posteo.de>
2023-05-15 16:17:45 +00:00
Benjamin Bouvier
c404e378a2 test: sliding sync list fields reloaded from the cache are observable in streams
Signed-off-by: Benjamin Bouvier <public@benj.me>
2023-05-15 17:46:04 +02:00
Jonas Platte
549edeb73b sdk: Instrument sliding response handling task 2023-05-15 17:24:02 +02:00
Benjamin Bouvier
b6302aca5c bench: add benchmarks for encrypted stores too
Signed-off-by: Benjamin Bouvier <public@benj.me>
2023-05-15 17:11:50 +02:00
Benjamin Bouvier
3928259bb5 bench: add restore session benchmark
Signed-off-by: Benjamin Bouvier <public@benj.me>
2023-05-15 17:11:50 +02:00
Richard van der Hoff
3049328078 matrix-sdk-crypto-js v0.1.0-alpha.9 2023-05-15 15:07:14 +01:00
Richard van der Hoff
3df473a56d update CHANGELOG 2023-05-15 15:07:03 +01:00
Ivan Enderlin
89384775ff chore(cargo): Update lockfile. 2023-05-15 16:04:17 +02:00
Ivan Enderlin
d2e9347be4 test(sdk): Put sliding_sync behind its feature flag. 2023-05-15 16:03:54 +02:00
Richard van der Hoff
18954a6ba5 crypto-js: fix body of SignatureUploadRequest (#1917)
Currently, the `body` of a `SignatureUploadRequest` includes a spurious
`signed_keys: {...}` property in which the actual content is wrapped. Fix that.
2023-05-15 15:02:01 +01:00
Chris Smith
3449dad89b feat(bindings): expose getting member by id
Allow for retrieving a single room member by their ID.
2023-05-15 15:26:45 +02:00
Ivan Enderlin
07267767fc test(sdk): New Sliding Sync integration test suite for a mocked server. 2023-05-15 15:19:45 +02:00
Ivan Enderlin
dca7800a88 chore(cargo): uuid is no longer needed. 2023-05-15 15:19:37 +02:00
Ivan Enderlin
caaeb8130d feat(sdk): Remove txn_id from requests sent by SlidingSync.
We were using `txn_id` as a way to identify the running stream. Now
things are cleaner so we can remove this “debug tool”. This class of
problems should not appear anymore. For the record, the biggest problem
was the following: It was possible to start multiple `stream`s at the
same time, and thus a stream could receive a response sent by another
stream. Since we no longer need to restart SlidingSync anymore (i.e. no
need to start multiple `stream`s at the same time), this problem should
not happen.
2023-05-15 15:16:40 +02:00
Ivan Enderlin
94d5d5187f test(sdk): Rename a test about SlidingSyncRoom. 2023-05-15 15:14:58 +02:00
Ivan Enderlin
d973ac1e93 doc(sdk): Add missing documentation. 2023-05-15 15:14:23 +02:00
Ivan Enderlin
6185b4050a feat(sdk): Process SlidingSync response inside handle_response.
Prior to this patch, the `v4::Response`, aka the SlidingSync response,
was processed by the client and transformed into a `SyncResponse` into
`sync_once` before being passed to `handle_response`. Now it's done in
`handle_response`.

This is not mandatory _now_, but it will be helpful in a close future.
2023-05-15 15:12:20 +02:00
Jonas Platte
ee87ec7b46 Improve logs for pagination 2023-05-15 13:06:30 +02:00
Jonas Platte
ab7aa68c5b Fix lints 2023-05-15 13:06:30 +02:00