Commit Graph

1919 Commits

Author SHA1 Message Date
Benjamin Bouvier
f5b6767253 feat(timeline): add a timeline start virtual item 2025-03-26 11:33:20 +01:00
Benjamin Bouvier
b83889dcba fix(ffi): propagate initial values before the future is picked by a runtime 2025-03-26 11:18:23 +01:00
Benjamin Bouvier
fc8a6dc9b1 refactor(ffi): always try to load InReplyToDetails from the event cache or network 2025-03-25 11:06:31 +01:00
Johannes Marbach
f8236a8b96 feat(timeline): add functions for sending messages in threads
`send_reply` is geared towards clients that don't render threads themselves. It sends a reply and optionally forwards it onto any existing thread.

This PR adds `send_thread_reply` for clients that do render threads themselves. This sends a message onto a thread, regardless of whether a thread existed before, and includes the fallback for non-threaded clients only if the message is not itself a reply on the thread.

Signed-off-by: Johannes Marbach <n0-0ne+github@mailbox.org>
2025-03-24 14:31:20 +01:00
Kévin Commaille
f6c5addf55 refactor(sdk): Remove experimental-oidc feature
Now that is compiles under WASM and that the API was cleaned up, it
should be okay.

Signed-off-by: Kévin Commaille <zecakeh@tedomum.fr>
2025-03-24 14:04:04 +02:00
Kévin Commaille
b3e82a05db refactor(oauth): Merge OAuth::login_with_oidc_callback() and OAuth::finish_login()
Accept a URL or a query string for simplicity.

That way we don't need to expose AuthorizationResponse.

Signed-off-by: Kévin Commaille <zecakeh@tedomum.fr>
2025-03-21 19:17:13 +01:00
Kévin Commaille
a8aa364757 refactor(oauth): Allow to use any registration method with OAuth::login
Gets rid of OAuth::url_for_oidc since it can be replaced by a call to
OAuth::login now.

Signed-off-by: Kévin Commaille <zecakeh@tedomum.fr>
2025-03-21 19:17:13 +01:00
Kévin Commaille
7457ecb1a8 feat(oauth): Allow to use any registration method with login_with_qr_code
Introduces the ClientRegistrationMethod type

Signed-off-by: Kévin Commaille <zecakeh@tedomum.fr>
2025-03-21 19:17:13 +01:00
Kévin Commaille
095425f664 refactor(oauth): Do not take static registrations in default OAuthRegistrationStore constructor
It complicates the constructor and most clients will probably not need to use it.

Signed-off-by: Kévin Commaille <zecakeh@tedomum.fr>
2025-03-21 10:49:46 +01:00
Kévin Commaille
ca4e212e98 refactor(oauth): Make OAuthRegistrationStore methods async
Since they perform blocking I/O we probably don't want to block a thread on that.

We use spawn_blocking, the alternative would be to use tokio::fs functions, which do the same thing and would require to load the whole file content in memory before (de)serialization.

Signed-off-by: Kévin Commaille <zecakeh@tedomum.fr>
2025-03-21 10:49:46 +01:00
Kévin Commaille
1a79ea94ed refactor(oauth): Improve OAuthRegistrationError variants
Make them more precise instead of wrapping several error types into a single variant.

Signed-off-by: Kévin Commaille <zecakeh@tedomum.fr>
2025-03-21 10:49:46 +01:00
Kévin Commaille
6803538c2e refactor(oauth): Rename OidcRegistrations to OAuthRegistrationStore
Use the same prefix as the other types in the OAuth 2.0 API, and use the
same suffix as other data-persisting APIs for consistency.

It also avoids to have two modules with very similar names, the only
difference being a trailing `s`.

Signed-off-by: Kévin Commaille <zecakeh@tedomum.fr>
2025-03-21 10:49:46 +01:00
Kévin Commaille
9d27e9b379 refactor(oauth): Make registrations module private
Since it only contains 2 types, it doesn't seem worth it to expose it,
we can just expose the types elsewhere.
2025-03-21 10:49:46 +01:00
Kévin Commaille
8683ca4d13 refactor(oauth): Re-export ClientID from the oauth module
Since it is now used everywhere, there is no reason to reexport it from
the registrations module.

Signed-off-by: Kévin Commaille <zecakeh@tedomum.fr>
2025-03-21 10:49:46 +01:00
Benjamin Bouvier
d4f5ac152a feat(ffi): log the log targets and levels 2025-03-21 09:37:25 +01:00
Benjamin Bouvier
31a1724390 feat(ffi): add support for log bundles 2025-03-21 09:37:25 +01:00
Kévin Commaille
45dd96e30a refactor(oauth): Merge finish_authorization and finish_login
That way users only need to call finish_login, since there is no other
reason to call finish_authorization currently.

Signed-off-by: Kévin Commaille <zecakeh@tedomum.fr>
2025-03-20 16:02:18 +00:00
Hugh Nimmo-Smith
3f4c1fd1bb feat(widgets, element-call): Update the widget url generation
Fixes: #4793

There was a previous PR https://github.com/matrix-org/matrix-rust-sdk/pull/4802 which attempted to implement this, but missed some backwards compatibility needs.

This updated PR has the original commit and then additional commits to add the compatibility (along with tests for the new intent param generally).
2025-03-20 14:28:45 +00:00
Benjamin Bouvier
5acaaf5865 fix(ffi): call the back-pagination status callback immediately 2025-03-20 10:26:54 +01:00
Hugh Nimmo-Smith
a0eb9340d5 Revert "feat(widgets, element-call) Update the widget url generation (#4802)"
This reverts commit 3b9ae3e65e.
2025-03-19 17:49:21 +01:00
Jonas Richard Richter
dbdbfd0b38 feat(notification): Add support for custom conditional push rules (#4587)
---
Signed-off-by: Jonas Richard Richter <jonas-richard.richter@telekom.de>
2025-03-19 12:50:02 +01:00
Timo
3b9ae3e65e feat(widgets, element-call) Update the widget url generation (#4802)
Fixes: https://github.com/matrix-org/matrix-rust-sdk/issues/4793

Co-authored-by: Valere <bill.carson@valrsoft.com>
2025-03-19 11:29:07 +02:00
Kévin Commaille
b9c970dc43 refactor(oauth): Rename OauthGrantType to OAuthGrantType
For consistency.

Signed-off-by: Kévin Commaille <zecakeh@tedomum.fr>
2025-03-18 17:18:34 +01:00
Kévin Commaille
ba5e395a59 refactor(oauth): Change Oauth prefix for error types to OAuth
For consistency.

Signed-off-by: Kévin Commaille <zecakeh@tedomum.fr>
2025-03-18 17:18:34 +01:00
Kévin Commaille
c0d3ed1a90 refactor(oauth): Rename provider_metadata to server_metadata
"Provider" is an OpenID Connect term. OAuth 2.0 uses the "authorization
server" term.

Signed-off-by: Kévin Commaille <zecakeh@tedomum.fr>
2025-03-18 17:18:34 +01:00
Kévin Commaille
00d7a77ebe refactor(encryption): Rename OidcCrossSigningResetInfo to OAuthCrossSigningResetInfo
Signed-off-by: Kévin Commaille <zecakeh@tedomum.fr>
2025-03-18 17:18:34 +01:00
Kévin Commaille
f29d3fd666 refactor(oauth): Rename OidcAuthCodeUrlBuilder to OAuthAuthCodeUrlBuilder
Signed-off-by: Kévin Commaille <zecakeh@tedomum.fr>
2025-03-18 17:18:34 +01:00
Kévin Commaille
47204830a9 refactor(oauth): Rename OidcError to OAuthError
Signed-off-by: Kévin Commaille <zecakeh@tedomum.fr>
2025-03-18 17:18:34 +01:00
Kévin Commaille
f4bb14a30e refactor(oauth): Rename OidcSession to OAuthSession
Signed-off-by: Kévin Commaille <zecakeh@tedomum.fr>
2025-03-18 17:18:34 +01:00
Kévin Commaille
6f3694cfa9 refactor(oauth): Rename Oidc API to OAuth
Signed-off-by: Kévin Commaille <zecakeh@tedomum.fr>
2025-03-18 17:18:34 +01:00
Kévin Commaille
1658610f93 refactor(sdk): Rename oidc module to oauth
Since we mostly use OAuth 2.0 now.

Signed-off-by: Kévin Commaille <zecakeh@tedomum.fr>
2025-03-18 17:18:34 +01:00
Kévin Commaille
7713ce768a refactor(oidc): Create ClientMetadata type
Signed-off-by: Kévin Commaille <zecakeh@tedomum.fr>
2025-03-14 18:03:34 +01:00
Kévin Commaille
6f44853bf7 refactor(oidc): Use Url for the issuer
Signed-off-by: Kévin Commaille <zecakeh@tedomum.fr>
2025-03-14 18:03:34 +01:00
Kévin Commaille
2c6c818005 refactor(oidc): Use ruma's server metadata type
Signed-off-by: Kévin Commaille <zecakeh@tedomum.fr>
2025-03-14 18:03:34 +01:00
Kévin Commaille
9adff21f78 refactor(oidc): Import code for building the account management URL
Signed-off-by: Kévin Commaille <zecakeh@tedomum.fr>
2025-03-14 18:03:34 +01:00
Jorge Martín
a941cc824d fix(ffi): Restore some needed OIDC prompts in the FFI layer
These prompts were used in the Element X app, probably in some other clients too.

Since Ruma removed these cases, we're just passing them as `_Custom(value)` ones, which do work.
2025-03-12 13:12:09 +01:00
Benjamin Bouvier
d3daa18bf8 feat!(ffi): rename setup_tracing into init_platform (#4790)
And make it take a boolean indicating whether we want to set up a
lightweight tokio runtime or not, instead of having
`setup_lightweight_tokio_runtime` as a public function + another
function, both of which would have to be called anyways.

cc @stefanceriu @jmartinesp
2025-03-12 09:41:01 +00:00
Ivan Enderlin
2ac3b6e9a2 chore(ffi): Remove useless block_on.
This patch removes the last `block_on` calls in `matrix-sdk-ffi`. Those
are artifacts of the past.
2025-03-11 16:37:44 +01:00
Benjamin Bouvier
01bb8093d0 feat(ffi): add a function to setup a lightweight tokio runtime
Creating many threads may use a bit of memory: on a machine with N
devices, exactly N*2 MB of memory may be consumed.

That might be a lot for a NSE process on iOS, which can only have up to
16 MB of RAM allocated for it. For this case, we introduce a new FFI
method `setup_lightweight_tokio_runtime` which will spawn at most 4
worker threads and 1 blocking thread. This should be sufficient for most
use cases.
2025-03-11 16:05:52 +01:00
Ivan Enderlin
1565067cee doc(ffi): Update the CHANGELOG.md. 2025-03-11 15:39:50 +01:00
Ivan Enderlin
ecc603171b feat(ffi): Add RoomInfo::encryption_state.
This patch adds the `EncryptionState` onto the new
`RoomInfo::encryption_state` field.
2025-03-11 15:39:50 +01:00
Ivan Enderlin
915cb13d45 fix(ffi): Remove Room::is_encrypted.
This API is now deprecated.
2025-03-11 14:03:42 +01:00
Kévin Commaille
0089da10cc refactor(ffi): Use methods on OidcConfiguration to construct parts
Changing the `TryInto` implementation into a method makes the code easier to follow.

Signed-off-by: Kévin Commaille <zecakeh@tedomum.fr>
2025-03-11 13:55:12 +01:00
Kévin Commaille
d3e64295cf refactor(oidc): Add redirect URI as an argument of url_for_oidc
Being able to always use the first redirect URI in the client metadata
seems to be very specific to the FFI bindings.

For example clients that need to bind a port on localhost need to
provide a custom redirect URI each time.

 So we ask for the redirect URI, and keep the current behavior only for
the bindings.

Signed-off-by: Kévin Commaille <zecakeh@tedomum.fr>
2025-03-11 13:55:12 +01:00
Kévin Commaille
6cd3217c2e refactor(oidc): Don't take the client metadata as an argument of url_for_oidc
The OidcRegistrations already hold the metadata. We can just clone it lazily when we need it.

Signed-off-by: Kévin Commaille <zecakeh@tedomum.fr>
2025-03-11 13:55:12 +01:00
Ivan Enderlin
eba2a7a6e3 doc(ffi): Update the CHANGELOG.md. 2025-03-11 12:28:16 +01:00
Ivan Enderlin
a98b822eeb feat(ffi): Replace Room::is_encrypted by encryption_state and latest_encryption_state. 2025-03-11 12:28:16 +01:00
Ivan Enderlin
d03ed3063c feat: Introduce EncryptionState.
This patch introduces the new `EncryptionState` to represent the 3
possible states: `Encrypted`, `NotEncrypted` or `Unknown`. All the
`is_encrypted` methods have been replaced by `encryption_state`.
The most noticable change is in `matrix_sdk::Room` where `async fn
is_encrypted(&self) -> Result<bool>` has been replaced by `fn fn
encryption_state(&self) -> EncryptionState`. However, a new `async
fn latest_encryption_state(&self) -> Result<EncryptionState>` method
“restores” the previous behaviour by calling `request_encryption_state`
if necessary.

The idea is that the caller is now responsible to call
`request_encryption_state` if desired, or use `latest_encryption_state`
to automate the call if necessary. `encryption_state` is now non-async
and infallible everywhere.

`matrix-sdk-ffi` has been updated but no methods have been added for
the moment.
2025-03-11 12:28:16 +01:00
Stefan Ceriu
ca025f8cca feat(ffi): forget the room when rejecting invites
- we're doing this as an extra layer of protection against spam attacks.
2025-03-11 10:16:27 +02:00
Stefan Ceriu
abe8338e5c chore(ffi): expose a method for retrieving rooms based on their identifier 2025-03-10 19:11:59 +02:00