Commit Graph

8320 Commits

Author SHA1 Message Date
Mauro Romito
8890bf3cee feat(bindings): improved and fixed ffi code 2024-02-29 14:10:45 +01:00
Mauro Romito
2e3ced1fb2 docs: more documentation 2024-02-29 12:58:34 +01:00
Mauro Romito
2163ab03ec tests: test improvements and added a new test 2024-02-29 12:48:49 +01:00
Mauro
4b1eefca80 Apply suggestions from code review
Co-authored-by: Ivan Enderlin <ivan@mnt.io>
Signed-off-by: Mauro <34335419+Velin92@users.noreply.github.com>
2024-02-29 11:52:31 +01:00
Mauro Romito
4dd7c3093c tests: improved the tests by adding the limit
into the check for the request
2024-02-28 19:41:31 +01:00
Mauro Romito
70466aafb4 docs: more documentation for types and the mod 2024-02-28 19:25:52 +01:00
Mauro Romito
3e35f163b7 docs: updated documentation
and removed code from ffi that will be changed soon
2024-02-28 19:17:58 +01:00
Mauro Romito
690ed4611d tests: unit tests have been completed 2024-02-28 19:01:42 +01:00
Mauro Romito
9c33540af8 tests: improved tests and added a unit test 2024-02-28 16:18:35 +01:00
Mauro Romito
37d95571e9 test: fixed a test by a adding a small delay 2024-02-27 17:40:03 +01:00
Mauro Romito
caa9a7d8be tests: code improvement for the filter integration test 2024-02-27 17:31:26 +01:00
Mauro Romito
d9231be1ba feat(bindings): listener code 2024-02-27 17:08:55 +01:00
Mauro Romito
26b0b32e55 feat(bindings): ffi layer started implementation
also improved the integration test for the filtered case
2024-02-27 14:37:22 +01:00
Mauro Romito
a79c5286d7 improved the tests 2024-02-27 10:58:13 +01:00
Mauro Romito
8ac6845607 feat: paginated public room search 2024-02-26 17:32:52 +01:00
Mauro Romito
18c155beb5 feat: room_directory_sync basic sync loop 2024-02-22 17:50:07 +01:00
Stefan Ceriu
0c1b6e45d5 latest event: Remove edits/replacements from the latest room event (#3150) 2024-02-22 15:19:00 +01:00
Ivan Enderlin
b5bda577dd chore(sdk): Remove useless imports or fix unused code. 2024-02-22 14:34:56 +01:00
Benjamin Bouvier
6593e32582 ffi: fix one clippy warning about ToOwned 2024-02-22 14:33:13 +01:00
Benjamin Bouvier
d3612ce35b event cache: give each RoomEventCache a sdk::Room
To do so, we need to put the weak reference `EventCache -> Client` back into the `EventCache`.

Putting the `sdk::Room` in the `RoomEventCache` will be useful to run room queries like backpagination (aka call `Room::messages()`).
2024-02-22 14:33:13 +01:00
Damir Jelić
bd6d0e959a backups: Better logs for decryption errors for backed up room keys 2024-02-21 16:08:32 +01:00
Benjamin Kampmann
cced512ad4 Keep the raw notification event around for further processing 2024-02-21 12:48:29 +01:00
Ivan Enderlin
06359b1166 fix(sdk): Race condition, doc, and Wasm in EventCache
fix(sdk): Race condition, doc, and Wasm in `EventCache`
2024-02-21 12:14:41 +01:00
Ivan Enderlin
10098d20c5 test(common): Add tests for spawn and JoinHandle::abort. 2024-02-21 12:01:08 +01:00
Ivan Enderlin
e4c8d6b708 chore(test): Remove a useless import. 2024-02-21 12:00:50 +01:00
Ivan Enderlin
6c6a8e2e77 chore(common): Remove useless import. 2024-02-21 10:54:31 +01:00
Andy Balaam
dcf0069753 export: Provide a streamed way to export keys
Signed-off-by: Andy Balaam <andy.balaam@matrix.org>
2024-02-20 16:06:24 +01:00
Andy Balaam
f0354d1fc5 export: Move existing export_room_keys method to Store
Signed-off-by: Andy Balaam <andy.balaam@matrix.org>
2024-02-20 15:18:52 +01:00
Damir Jelić
6634735065 ffi: Let the auth service use a proxy as well
The ClientBuilder already exposes setting the proxy, but sadly the
AuthService doesn't let you configure the ClientBuilder directly (yet).

So logging in with a proxy wasn't supported until now.
2024-02-20 15:15:49 +01:00
Stefan Ceriu
59c468c758 Switch user ignoring/unignoring methods to full async 2024-02-20 13:51:18 +01:00
Stefan Ceriu
c6e93b06a3 Log ignored user list event deserialization errors 2024-02-20 13:51:18 +01:00
Stefan Ceriu
89033cd13a Fixes #3141 - Expose ignored users on the FFI layer 2024-02-20 13:51:18 +01:00
Valere
88a70f472f Discard session API and bindings for Room (#2941)
Co-authored-by: Damir Jelić <poljar@termina.org.uk>
2024-02-20 13:36:55 +01:00
Doug
fafd1a403c fix: Use from macro on wrapped error. 2024-02-20 13:32:46 +01:00
Doug
371cc24031 fix: Update Swift test, remove pub access on sanitize_server_name
Removed a test that was pinging matrix.org too.
2024-02-20 13:32:46 +01:00
Doug
2538ba68c5 ffi: Expose more server discovery errors. 2024-02-20 13:32:46 +01:00
Doug
14e93e8c0c ffi: Use server_name_or_homeserver_url directly. 2024-02-20 13:32:46 +01:00
Jorge Martín
54bdb7791c ffi: Add extra logs to Client::process_session_change
This should help us understand why 2 failed requests with invalid access token didn't pass a refreshed token to the client.
2024-02-20 11:44:02 +01:00
Ivan Enderlin
2f97bc2bae feat(sdk): Improve performance of EventCacheInner::for_room. 2024-02-19 20:08:28 +01:00
Ivan Enderlin
7e3e8fff55 feat(common): Implement JoinHandle::abort on wasm32-u-u.
This patch implements `JoinHandle::abort` when `cfg(target_arch =
"wasm32")`.

The idea is to combine `RemoteHandle` and `AbortHandle`.
2024-02-19 18:21:20 +01:00
Ivan Enderlin
8d878b6785 fix(sdk): Fix a race condition in EventCacheInner::for_room.
There is a race condition in `EventCacheInner::for_room`. Before this
patch, it was possible for 2 concurrent execution to do the following:

* Execution 1 takes the read lock; there is no room in `by_room`, so it
  creates the `RoomEventCache`, code is suspended while trying to get
  the write lock.
* Execution 2 takes the read lock; there is no room in `by_room`, so it
  creates the `RoomEventCache`, code is _not_ suspended because _insert
  reason_, the write lock is acquired, and the `RoomEventCache` is saved
  and a shallow clone is returned.
* Execution 1 resumes, the write lock is acquired, the `RoomEventCache`
  overwrites the one from Execution 2, and a shallow clone is returned.

Now Execution 2 holds a `RoomEventCache` that isn't saved in `by_room`.
It's a ghost! Worst, because the store is cloned in both
`RoomEventCache`, 2 versions will overwrite themselves in the store
constantly.

This patch uses a single write lock, and uses the `BTreeMap::entry`
API instead. Thus, the race condition disappears.

This patch also changes the return type of `for_room` to make it
infallible. It was already the case: only the `Ok` value was returned.
2024-02-19 16:40:11 +01:00
Ivan Enderlin
add06bf897 doc(sdk): Add some documentation about the EventCache. 2024-02-19 16:40:11 +01:00
Ivan Enderlin
e5b07aa827 chore(sdk): Move EventCache::drop_handles inside EventCacheInner.
This patch moves `EventCache::drop_handles` inside `EventCacheInner` for
the sake of simplicity.
2024-02-19 16:40:11 +01:00
Ivan Enderlin
814d78708e feat(sdk): EventCache uses matrix_sdk_common::executor::spawn.
This patch imports the `spawn` function from
`matrix_sdk_common::executor` instead of `tokio`.
`matrix_sdk_common::executor` adds support for WebAssembly.
2024-02-19 16:40:11 +01:00
Ivan Enderlin
88d7a2fe28 feat(ui,ffi): Add the favourite room list filter
feat(ui,ffi): Add the `favourite` room list filter
2024-02-19 13:45:37 +01:00
Benjamin Bouvier
5386e9e838 event cache: have a single EventCache instance per Client, at most (#3136)
* event cache: move it to the main SDK crate

* event cache: add requested Debug impl to `RoomEventCacheUpdate`

Somehow the compiler asked for it now...

* event cache: add missing copyright notice to store file

* event cache: use a weak reference to the client internally

This will make it possible to have the `Client` own an `EventCache` without a reference
cycle.

* event cache: move the spawned task to its own function

* event cache: move RwLock from EventCache::inner to the only mutable field inside EventCacheInner

* event cache: have the Client own *the* event cache

The goal is to have a unique EventCache instance overall, that's available from everywhere in
the SDK, notably when creating timelines for rooms.

Because the event cache only owns a weak reference to the client, it means the Client still
can be dropped, In turn, this will close its sender of `RoomUpdates`, which will gracefully
close the task spawned in `EventCache::new` after it's done handling the latest updates.

* event cache: process room updates one at a time

* timeline: use the client-wide event cache instead of spawning one per timeline

This now means that we're passing the "initial events" to the event cache just before initializing
the timeline. As a result, there might be previous events that the event cache saw (coming from
sync), but now we can't decide where to put them; drop previously known events in that case.

* event cache: hey, turns out we don't even need the weak back-link

Keeping it as a separate commit, to make it easier to revert later.

* event cache: remove unused errors

Keeping the error type and results, though, because we might have store errors soonish.

* fixup! event cache: move the spawned task to its own function

* event cache: manually subscribe to the event cache

It was a bad idea to have it enabled by default, since some users may not be interested in all
updates for all rooms (e.g. bots). Instead, we make it so that the event cache must be
explicitly subscribed to, and we do it in two cases:

- in the UI `TimelineBuilder::build` method, because we're interested in updates to the current
  room,
- in the `RoomListService`, because we *will* be interested in updates to room derived data (e.g.
  unread counts, read receipts, and so on).

This avoids a bit of fiddling when creating the event cache in the client.

This is resilient when a parent Client is forked into a child Client, because the child
`EventCache` share the same subscription as the parent's.
2024-02-19 12:39:31 +00:00
Ivan Enderlin
9e6252cb2d doc(ui): Add missing copyright headers. 2024-02-19 13:33:11 +01:00
Ivan Enderlin
12d5f51051 feat(ffi): Add the favourite room list filter.
This patch implements the `RoomListEntriesDynamicFilterKind::Favourite`
variant.
2024-02-19 13:29:56 +01:00
Ivan Enderlin
c7d34bd65e doc(ui): Add documentation for matrix_sdk_ui::room_list_service::filters.
This patch adds missing documentation for the `filters` module.
2024-02-19 13:29:56 +01:00
Ivan Enderlin
900a6d1382 feat(ui): Add the favourite filter.
This patch adds the `favourite` filter, to filter out rooms that are not
marked as favourite.
2024-02-19 13:29:56 +01:00