Commit Graph

11442 Commits

Author SHA1 Message Date
Richard van der Hoff
6e480271d3 crypto: get_most_recent_session: return None for unknown device (#4846)
If we have a device whose Curve25519 key we don't know, then
self-evidently we can't have any active Olm sessions with that device.
Currently, we return an `EventError::MissingSenderKey` in this case, but
(a) the definition of that error doesn't match this situation, and (b)
it complicates handling in methods that call `DeviceData::encrypt`
(currently only `DeviceData::maybe_encrypt_room_key`, but I want to add
a second).

Other than `DeviceData::encrypt`, the only place where
`get_most_recent_session` is called is `mark_device_as_wedged`. In that
case, we have just looked up the device by its Curve25519 key, so we
know it must have one.

We can therefore be reasonably certain that this change is a no-op.
2025-03-26 14:42:24 +00:00
Ivan Enderlin
e60cf18337 refactor(base): Rename BaseClient::with_store_config to new.
This renames the `BaseClient::with_store_config` constructor to `new`:

1. there is no alternative constructor, it's the only one,
2. the `with_` prefix is usually reserved to (i) builders or (ii)
   alternative constructors,
3. I believe it clarifies the code.
2025-03-26 15:34:08 +01:00
Ivan Enderlin
6409adb879 doc(base): Remove an empty line in an example. 2025-03-26 15:34:08 +01:00
Ivan Enderlin
915e0e83bc doc(base): Fix documentation of BaseClient::with_store_config.
The documentation is outdated, `config` is now a `StoreConfig`.
2025-03-26 15:34:08 +01:00
Ivan Enderlin
8323ecdc8b doc(base): Improve documentation of BaseClient.
This patch:

* fixes the mention of “no IO”, it lacks the “network” part,
* adds an example of how to build a `BaseClient`,
* mentions that it is better be used via `matrix_sdk`.
2025-03-26 15:34:08 +01:00
Kévin Commaille
e0e9c06ca4 Don't use serde to avoid returning an error
Signed-off-by: Kévin Commaille <zecakeh@tedomum.fr>
2025-03-26 15:26:55 +01:00
Kévin Commaille
eb313efdeb Don't qualify error! macro
It's already imported.

Signed-off-by: Kévin Commaille <zecakeh@tedomum.fr>
2025-03-26 15:26:55 +01:00
Kévin Commaille
bc22ff1221 refactor(oauth): Introduce AccountManagementUrlBuilder
It allows to reuse the URL for different actions more easily than having
to call `OAuth::account_management_url` every time for a different
action.

It also adds a method with fallback if we want to ignore action
serialization errors, to always present a URL.

Signed-off-by: Kévin Commaille <zecakeh@tedomum.fr>
2025-03-26 15:26:55 +01:00
Benjamin Bouvier
8c988beaf2 doc(linked chunk): tweak comments related to clearing/dropping a linked chunk 2025-03-26 11:57:48 +01:00
Benjamin Bouvier
752c9baf7c refactor(timeline): simplify removal of duplicated local echo item 2025-03-26 11:33:20 +01:00
Benjamin Bouvier
766772f654 feat(timeline): insert the start of the timeline in places where it's required 2025-03-26 11:33:20 +01:00
Benjamin Bouvier
f5b6767253 feat(timeline): add a timeline start virtual item 2025-03-26 11:33:20 +01:00
Benjamin Bouvier
5ce045ee02 refactor(timeline): avoid unnecessary shadowing variables 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
Ivan Enderlin
cfc839f71b doc(sqlite) Add entry to the changelog. 2025-03-26 11:01:52 +01:00
Ivan Enderlin
660d4e7ccb feat(sqlite): Add StoreOpenConfig and open_with_config for all stores.
This patch adds a new `StoreOpenConfing` type to configure the store
when opening it and when creating the pool of connections to SQLite via
`deadpool_sqlite`.

This patch also adds a new `open_with_config` constructor on all
stores, namely `SqliteCryptoStore`, `SqliteEventCacheStore` and
`SqliteStateStore`.
2025-03-26 11:01:52 +01:00
Benjamin Bouvier
404dd3949f test: remove unused helpers 2025-03-26 11:01:14 +01:00
Benjamin Bouvier
693c8df8d0 test(timeline): more of the same, with a new EventFactory method to add a receipt with a given timestamp 2025-03-26 11:01:14 +01:00
Benjamin Bouvier
d587d5f145 test(timeline): make more use of MatrixMockServer / EventFactory 2025-03-26 11:01:14 +01:00
Benjamin Bouvier
be6daa5930 test: add EventFactory::typing for typing notifications and get rid of more old cruft 2025-03-26 11:01:14 +01:00
Benjamin Bouvier
acee5415c5 test: get rid of a few global statics for read receipts event contents 2025-03-26 11:01:14 +01:00
Benjamin Bouvier
6399a99452 test(timeline): use the EventFactory a bit more 2025-03-26 11:01:14 +01:00
Benjamin Bouvier
b5aa2113db test: add a way to create ephemeral read receipts events in the EventFactory 2025-03-26 11:01:14 +01:00
Benjamin Bouvier
1585b0c32e test(timeline): use more MatrixMockServer 2025-03-26 11:01:14 +01:00
Benjamin Bouvier
3c01f88ab8 benchmark(linked chunk): add a benchmark for reading events out of the store 2025-03-26 10:29:01 +01:00
Benjamin Bouvier
785312856e fix(linked chunk): don't leak upon drop
The previous code in `LinkedChunk::drop()` would call `clear()`, which
would reset the chunk to an empty events chunk; preinitializing a vector
of 128 items. But this item chunk would never be dropped, so this would
cause a leak.

The solution is to split the semantics of *resetting* a linked chunk
(what was called `clear` before), from *clearing* it: clearing will put
it in an dangling state, and it's the caller's responsibility to do
something about it; as such, it's marked unsafe. `LinkedChunk::drop()`
may now call `clear()` (which is fine; last use of the linked chunk);
and `LinkedChunk::reset()` will call `clear()` and reset the first
chunk, which is fine too.
2025-03-26 10:29:01 +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
Benjamin Bouvier
7b8694e465 refactor(timeline): better encapsulate RepliedToEvent's fields 2025-03-25 11:06:31 +01:00
Benjamin Bouvier
655f62c331 refactor(timeline): don't ever look into the timeline's items to fetch the replied-to event content
This is a nice simplification, because this means that:

1. we use a single way to get the event (event-cache-or-network)
2. we don't have to reconstruct a `RoomMessageEventContent` from a
timeline's message, which seems a bit error prone
3. there's a single way to get the replied-to info for an event,
4. and that's actually independent of the timeline, so we can improve
the code for #4835
2025-03-25 11:06:31 +01:00
Benjamin Bouvier
53732e0ff2 refactor(timeline): use load_or_fetch_event when fetching a reply's content 2025-03-25 11:06:31 +01:00
Benjamin Bouvier
4cae122854 refactor(room): use load_or_fetch_event when creating an edit event 2025-03-25 11:06:31 +01:00
Benjamin Bouvier
2a11494c33 feat(room): introduce a new method to load from cache or network 2025-03-25 11:06:31 +01:00
Benjamin Bouvier
1dddd97d96 refactor(timeline): simplify ReplyContent::Message 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
aa07108c98 fix(oauth): Put cross-process module behind e2e-encryption feature
Since it requires the crypto store.

Signed-off-by: Kévin Commaille <zecakeh@tedomum.fr>
2025-03-24 14:04:04 +02:00
Kévin Commaille
9aed0cc933 chore: Add changelog about experimental-oidc feature removal
Signed-off-by: Kévin Commaille <zecakeh@tedomum.fr>
2025-03-24 14:04:04 +02: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
9434a112d9 fix(oauth): Don't run OAuth tests under WASM
They almost all require a mock server.

Signed-off-by: Kévin Commaille <zecakeh@tedomum.fr>
2025-03-24 14:04:04 +02:00
Kévin Commaille
c4ec32cb78 fix(sdk): Gate QR login imports and methods for WASM
Signed-off-by: Kévin Commaille <zecakeh@tedomum.fr>
2025-03-24 14:04:04 +02:00
Kévin Commaille
c5b8c812b3 fix(oauth): Use WASM-compatible types from matrix-sdk-common
Signed-off-by: Kévin Commaille <zecakeh@tedomum.fr>
2025-03-24 14:04:04 +02:00
Kévin Commaille
fdc2ca0c9e fix(oauth): Do not expose OAuthRegistrationStore under wasm32
It usually won't be possible to write data to a file.

Signed-off-by: Kévin Commaille <zecakeh@tedomum.fr>
2025-03-24 14:04:04 +02:00
Kévin Commaille
dcd0e078f6 docs(qr-login): Update docs
Signed-off-by: Kévin Commaille <zecakeh@tedomum.fr>
matrix-sdk-ffi/20250325
2025-03-24 09:32:05 +00:00
Kévin Commaille
78b79a758f feat(oauth-cli): Use OAuthRegistrationStore
It's probably the recommended way to do registration when the client can create files.

Signed-off-by: Kévin Commaille <zecakeh@tedomum.fr>
2025-03-24 09:32:05 +00:00
Kévin Commaille
29f6606d99 refactor(examples): Rename oidc_cli to oauth_cli
And update the docs.

Signed-off-by: Kévin Commaille <zecakeh@tedomum.fr>
2025-03-24 09:32:05 +00:00
Kévin Commaille
94f0beec51 chore: Add changelog for login with registration methods
Signed-off-by: Kévin Commaille <zecakeh@tedomum.fr>
2025-03-21 19:17:13 +01:00
Kévin Commaille
590d1d7890 test(oauth): Add test for OAuth::use_registration_method
Signed-off-by: Kévin Commaille <zecakeh@tedomum.fr>
2025-03-21 19:17:13 +01:00
Kévin Commaille
400c92fc89 refactor(oauth): Reuse the AuthorizationServerMetadata when possible
Avoids repeated calls to the same endpoint in the same flow.

Signed-off-by: Kévin Commaille <zecakeh@tedomum.fr>
2025-03-21 19:17:13 +01: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