Commit Graph

13223 Commits

Author SHA1 Message Date
Benjamin Bouvier c41f7975b3 labs: turn rrrepl into a timeline client 2024-03-08 16:08:29 +01:00
Jorge Martin Espinosa cb6b420ad0 ffi: add previous power levels to OtherState::RoomPowerLevels (#3199)
This is needed to be able to diff between increases and decreases of power levels ("user Alice was promoted Admin", etc.).

---

* ffi: add `previous` power levels to `OtherState::RoomPowerLevels`

This is needed to be able to diff between increases and decreases of power levels.

* ffi: please clippy

* ffi: inline initialization of `previous` and `users`
2024-03-08 15:03:02 +00:00
Hanadi 724d133cce sdk&ffi: server unstable features support for MSC4028 (#3192)
Fixes https://github.com/matrix-org/matrix-rust-sdk/issues/3191

Allows support for fetching the unstable_features from `/_matrix/clients/versions`.
Specifically, to be used for checking the state of org.matrix.msc4028 through ffi to the clients.

---

* sdk: fetch unstable_features supported by homeserver

Signed-off-by: hanadi92 <hanadi.tamimi@gmail.com>

* ffi: add can_homeserver_push_encrypted_event_to_device method

Signed-off-by: hanadi92 <hanadi.tamimi@gmail.com>

* fix: use copied instead of dereferencing

Co-authored-by: Benjamin Bouvier <public@benj.me>
Signed-off-by: Hanadi <hanadi.tamimi@gmail.com>

* fix: move can_homeserver_push_encrypted_event_to_device logic to sdk

Signed-off-by: hanadi92 <hanadi.tamimi@gmail.com>

* fix: remove unused unstable features param in client builder

Signed-off-by: hanadi92 <hanadi.tamimi@gmail.com>

* fix: use assert instead of asserteq for bool check

Signed-off-by: hanadi92 <hanadi.tamimi@gmail.com>

* fix: documentation

Signed-off-by: hanadi92 <hanadi.tamimi@gmail.com>

* Apply suggestions from code review

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

---------

Signed-off-by: hanadi92 <hanadi.tamimi@gmail.com>
Signed-off-by: Hanadi <hanadi.tamimi@gmail.com>
Signed-off-by: Benjamin Bouvier <public@benj.me>
Co-authored-by: Benjamin Bouvier <public@benj.me>
2024-03-08 11:28:04 +01:00
Benjamin Bouvier b7d6fd08f1 event cache: enforce unique access on the EventCacheStore 2024-03-07 18:57:57 +01:00
Jorge Martin Espinosa 0469c27b91 ffi: Add methods to get and reset the power levels of a Room
- `Room::build_power_level_changes_from_current()` was replaced by `Room::get_power_levels()`, which now returns an SDK/Ruma `RoomPowerLevels` value containing all the data we need to display these values in UI and not only the customised values.
- `Room::reset_power_levels()` was added to the FFI layer.
2024-03-07 12:46:13 +01:00
Benjamin Kampmann f14c00db82 store: Add a method to set a custom value without reading and returning the old value
This is useful if we don't care about the old value, which lets us avoid unnecessary reads.
2024-03-07 12:02:32 +01:00
Johannes Marbach a204b2994d chore: improve create_room documentation
Signed-off-by: Johannes Marbach <n0-0ne+github@mailbox.org>
2024-03-06 09:52:23 +01:00
Mauro 3f627f4125 Merge branch 'main' into mauroromito/directory_search 2024-03-05 11:44:15 +01:00
dependabot[bot] 98a68632df chore(deps): bump mio from 0.8.10 to 0.8.11
Bumps [mio](https://github.com/tokio-rs/mio) from 0.8.10 to 0.8.11.
- [Release notes](https://github.com/tokio-rs/mio/releases)
- [Changelog](https://github.com/tokio-rs/mio/blob/master/CHANGELOG.md)
- [Commits](https://github.com/tokio-rs/mio/compare/v0.8.10...v0.8.11)

---
updated-dependencies:
- dependency-name: mio
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
2024-03-05 10:42:26 +01:00
Jorge Martin Espinosa 0c98e26a05 sdk: create new users_with_power_levels fn (#3182)
It maps user ids to users' power levels.

Also, make sure it just returns an empty map if this info is not available, instead of crashing. 

Then use it in the FFI side to output updated data for the `RoomInfo`.

---

* sdk: create new `users_with_power_levels` fn which maps user ids to users' power levels

Also, make sure it just returns an empty map if this info is not available, instead of crashing.

* Update crates/matrix-sdk/src/room/mod.rs

Co-authored-by: Benjamin Bouvier <public@benj.me>
Signed-off-by: Jorge Martin Espinosa <angel.arasthel@gmail.com>

* Improve tests

---------

Signed-off-by: Jorge Martin Espinosa <angel.arasthel@gmail.com>
Co-authored-by: Benjamin Bouvier <public@benj.me>
2024-03-04 16:37:16 +01:00
Benjamin Bouvier 4b56ca1841 event cache: remove the RoomNotFound error
Having `EventCache::for_room` return an `Option` avoids the need for the error. One caller can
safely unwrap it, and others can log and ignore rooms that have disappeared (like we do in `call_sync_response_handlers`).
2024-03-04 15:11:14 +01:00
Benjamin Bouvier 8d2e790bca event cache: add a Room::event_cache() method
This keeps the `RoomNotFound` error, which could still happen in theory if the `EventCache` is
being misused internally.
2024-03-04 15:11:14 +01:00
Stefan Ceriu e4be216731 feat: add support for m.call.invite events in the timeline and as a last room message 2024-03-04 14:57:01 +01:00
Benjamin Bouvier 74727e5f84 ci: update codecov action to v4 2024-03-04 12:25:19 +01:00
Andy Balaam 4b711e4b37 Merge pull request #3177 from matrix-org/doug/multi-user-power-levels
FFI: Update the power levels of multiple users at once.
2024-03-04 10:10:28 +00:00
Mauro Romito 4db69647ce Merge branch 'mauroromito/directory_search' of github.com:matrix-org/matrix-rust-sdk into mauroromito/directory_search 2024-03-01 17:25:16 +01:00
Mauro Romito e922a58cc3 tests: fix fmt 2024-03-01 17:25:11 +01:00
Mauro eb0ddbc063 Merge branch 'main' into mauroromito/directory_search 2024-03-01 17:18:08 +01:00
Mauro Romito 9fbc2ab07c mocking library not supported on wasm 2024-03-01 17:17:24 +01:00
Mauro Romito 2f7b2f0451 fix: fmt 2024-03-01 17:07:52 +01:00
Mauro Romito ad1623da58 docs: fixed docs 2024-03-01 15:44:24 +01:00
Mauro Romito 2abe3aba4a improved docs 2024-03-01 15:21:57 +01:00
Andy Balaam 82684d64d4 Merge pull request #3180 from matrix-org/jme/bump-uniffi-referenced-commit-so-android-works-again
ffi: bump the UniFFi referenced commit again
2024-03-01 13:27:53 +00:00
Jorge Martín 7b40daa3cf ffi: bump the UniFFi referenced commit again
At the moment, the SDK can't be built for Android because of these 2 issues:

- https://github.com/mozilla/uniffi-rs/issues/1996
- https://github.com/mozilla/uniffi-rs/issues/1995

Those have been fixed in the new commit.
2024-03-01 13:59:12 +01:00
Timo Kösters 5ee3897f7e ffi: aggregate RoomMember fields early instead of requiring to call getters (#3172)
This does two things:

- raise the timeout value for the `/members` queries, because they can super slow in Synapse because of nasal demons,
- and aggregate all the fields of `RoomMember` early, so users don't have to call getters to read each field.

---

* room_members: Export plain old data for room members to avoid FFI calls

Signed-off-by: Timo Kösters <timo@koesters.xyz>

* room_member: Respond to review feedback

* room_member: Remove previous RoomMember struct

* ffi: rename ExportedRoomMember to RoomMember

---------

Signed-off-by: Timo Kösters <timo@koesters.xyz>
Co-authored-by: Benjamin Bouvier <public@benj.me>
2024-02-29 17:27:21 +01:00
Benjamin Bouvier 370f4735f7 ffi: simplify the declaration type 2024-02-29 15:03:45 +01:00
Mauro 77ba3010cc Merge branch 'main' into mauroromito/directory_search 2024-02-29 14:29:31 +01:00
Mauro Romito b2b9b5fa12 feat(bindings): reverted some code from ffi 2024-02-29 14:29:03 +01:00
Doug c251f16292 ffi: Update the power levels of multiple users as once. 2024-02-29 13:12:30 +00:00
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
Stefan Ceriu 8392ef07cd ffi: bump uniffi to latest git rev to generate open swift classes 2024-02-28 18:46:26 +01:00
Mauro Romito 9c33540af8 tests: improved tests and added a unit test 2024-02-28 16:18:35 +01:00
Doug 0401b995b7 ffi: Expose getting a power level from a role. 2024-02-28 13:27:10 +01:00
Andy Balaam 0521d23e94 Merge pull request #3167 from matrix-org/andybalaam/doc-fixes-e2ee
docs: Punctuation and wording fixes in encryption docs
2024-02-28 09:56:19 +00: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
Jorge Martin Espinosa 2068e7f266 sdk & ffi: add user power levels and role getter to RoomInfo (#3170)
Changes:
- sdk: Add `get_user_power_level` and `get_suggested_user_role` functions so we don't need to load the whole room member list to know if a user has some power level/role.
- ffi: add an FFI fn for `get_suggested_user_role`.
- ffi: add `user_power_levels` to `RoomInfo`.

The goal of this PR is being able to fetch a user's power level or role almost immediately and avoid having to load and find the user in the room member list, which can be very slow to load (especially in EX Android).

---

* sdk: Add `get_user_power_level` and `get_suggested_user_role` functions to get the power level for a user without loading the room member list.

* ffi: add `suggested_role_for_user` fn, which calls the new `get_suggested_user_role` fn in Room

* sdk: add test

* ffi: add user power level info to `RoomInfo`

* Add changes to changelog

* sdk: Fix docs formatting

* sdk & ffi: use `&UserId` instead of `OwnedUserId`

Also, simplify error mapping.

* sdk: add extra test

* ffi: fix `OwnedUserId` -> `&UserId` conversion

* sdk: Replace `UserId::parse` with `user_id!` macro for literals in tests

* Update crates/matrix-sdk/tests/integration/room/joined.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-02-27 16:04:08 +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
Andy Balaam c7f3e2ad1d docs: Punctuation and wording fixes in encryption docs
Signed-off-by: Andy Balaam <andy.balaam@matrix.org>
2024-02-27 10:16:03 +00: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
Benjamin Bouvier 9f75552c9b event cache: only emit an event update when there are, well, events to propagate
Mostly an optimization that was also revealed by the previous version of the test failing, because it would receive an initial update with empty
events.
2024-02-26 16:05:23 +01:00