Commit Graph

9002 Commits

Author SHA1 Message Date
Benjamin Bouvier
a21ea06bed day dividers: demote an assert to an error message
Because of the task cancellation that can happen at any place in the
code base, it's really hard to predict in which situation a
day-divider-adjuster should have run or not, so just demote the assert
to an error. The intent is that, if we see errors with day dividers in
the future, they'll be reported along rageshakes and we'll notice this
in the logs.
2024-06-06 18:05:21 +02:00
Benjamin Bouvier
66330a20b3 sdk: rename "sending queue" to "send queue" 2024-06-06 17:56:17 +02:00
Doug
3f272a72c4 chore: Update some docs on the authentication service. 2024-06-06 17:01:46 +02:00
Doug
81b55a4ca8 ffi: Use a single client in the authentication service.
We no longer need the in-memory store as we provide a path for the new session.
2024-06-06 17:01:46 +02:00
Doug
d43812ac04 ffi: Replace the Client's base_path with a session_path.
The SDK no longer handles subdirectories for the user, this becomes the app's responsibility.
2024-06-06 17:01:46 +02:00
Doug
2c87333106 oidc: Supply a direct path to the registrations file instead of a base path. 2024-06-06 17:01:46 +02:00
Benjamin Bouvier
5093af87b1 clippy: disallow useless asyncs (#3513)
Using async when not required will increase compile times, and propagate async-ness to the callers, transitively.

See also the [lint description](https://rust-lang.github.io/rust-clippy/master/#/unused_async).

Since we only had a few false positives, I've enabled it by default.
2024-06-05 17:13:10 +02:00
Benjamin Bouvier
23cc1e31c1 ffi: make more methods async, rename a few variables/functions, etc. 2024-06-05 14:58:41 +02:00
Benjamin Bouvier
96824055f8 ffi: add new method to retrieve a timeline item by transaction id 2024-06-05 14:58:41 +02:00
Benjamin Bouvier
cb9e2bda92 timeline: mark local echoes as not editable
Also reunify two methods that did the same thing, with slightly
different semantics, and test the one that wasn't tested at all.

Note that `is_editable()` was already exposed to the FFI and used in EX
apps.
2024-06-05 14:58:41 +02:00
Benjamin Bouvier
04befa3ab5 timeline: get rid of the Cancelled state
It was used after a previous local echo couldn't be sent (i.e. the
sending queue failed to send it). However, it was slightly incorrect to
mark those as cancelled, since those local echoes would still have
corresponding items in the sending queue, and would be retried as soon
as the sending queue was reenabled and could send events.

Instead, this is removed: it means that previously cancelled events
would be in the NotSentYet state, which is correct. (At the limit, we
could even get rid of the SendingFailed variant, since the sending queue
will automatically retry as soon as possible.)
2024-06-05 14:58:41 +02:00
Benjamin Bouvier
fd15333ba2 timeline: add a redact method to get rid of local or remote events 2024-06-05 14:58:41 +02:00
Benjamin Bouvier
68c61ef8e1 send queue: add an abort handle to all local echoes 2024-06-05 14:58:41 +02:00
Benjamin Bouvier
fd9266e960 ffi: expose the abort handle after sending an event 2024-06-05 14:58:41 +02:00
Benjamin Bouvier
5ea7ef01e5 ffi: expose the global sending queue primitives 2024-06-05 14:58:41 +02:00
Benjamin Bouvier
3693c582c3 integration tests: update reactions test to check if an event is a local echo
The test relied on the fact that sending an event from a given timeline
is not observable from another timeline. Indeed, it sent a message using
a first timeline object, then constructed a second timeline object and
expected only the remote event to be in there.

Now, the sending queue is shared across all instances of a Room, thus
all instances of a Timeline, and the second timeline can see the local
echo for the message sent by the first timeline.

The "fix" is thus in the test structure itself: when waiting for the
remote echo to be there, check that the timeline item doesn't pertain to
a local echo, i.e. is a remote echo.
2024-06-05 14:58:41 +02:00
Benjamin Bouvier
8101879799 timeline: clarify in some names that events are remote 2024-06-05 14:58:41 +02:00
Benjamin Bouvier
ec95ca6ed1 timeline: only spawn the local echo listener if we're a live timeline
Technically, the test already passed before the change in the builder,
because `TimelineEventHandler::handle_event` already filters out local
events on non-live timelines, but it's a waste of resources to even
spawn the local echo listener task in that case, so let's not do it.
2024-06-05 14:58:41 +02:00
Benjamin Bouvier
b88381a289 timeline: use the new sending queue mechanism to send and receive local echoes 2024-06-05 14:58:41 +02:00
Benjamin Bouvier
3917ba67c9 ffi: add a reference to the FFI Client to the Encryption API object
By keeping a reference to the FFI Client, we make sure that the SDK
Client is dropped while in a tokio runtime context. This makes it
possible for an `Encryption` (FFI) object to outlive the `Client` (FFI)
object without crashing (because deadpool requires to be in a tokio
runtime context when dropping).
2024-06-05 13:48:39 +02:00
Benjamin Bouvier
c1030562c3 authentication service: inline details_from_client() 2024-06-05 13:48:39 +02:00
Benjamin Bouvier
e6185b3827 authentication service(ffi): don't set the base_path for the temporary discovery client
Following https://github.com/matrix-org/matrix-rust-sdk/pull/3473, we
made it so that if there's a base-path but no username, then we'll
create a sqlite database.

Unfortunately, this introduced a bad side-effect: for the temporary
client used during homeserver resolution, this would create a temporary
sqlite database.

The "fix" is to not set the base path for the temporary client, and only
for the other caller of `new_client_builder()`, manually. The long term
fix is to get rid of the `AuthenticationService` so we can test it
properly.
2024-06-05 13:48:39 +02:00
Benjamin Bouvier
13df762dc1 ffi: add more logs related to the path in the client builder 2024-06-05 13:48:39 +02:00
Ivan Enderlin
ec5f94f0b4 feat(base): Update Ruma to get RoomSummary::heroes as Vec<OwnedUserId>
feat(base): Update Ruma to get `RoomSummary::heroes` as `Vec<OwnedUserId>`
2024-06-05 10:51:38 +02:00
Ivan Enderlin
420a69f9de feat(base): Update Ruma to get RoomSummary::heroes as Vec<OwnedUserId>.
This patch updates Ruma to 75e8829 so that `RoomSummary::heroes` is now
a `Vec<OwnedUserId>` instead of a `Vec<String>`. This patch updates our
code accordingly by removing the parsing of heroes as `OwnedUserId`.
2024-06-05 10:38:03 +02:00
Benjamin Bouvier
ec5f5bc104 room preview integration test: explicitly request some state events to sync
Another attempt at fixing #3483.
2024-06-05 10:08:52 +02:00
Benjamin Bouvier
9d46da9f11 clippy: fix additional errors
We should investigate why some errors were not found in CI tasks,
though.
2024-06-05 09:34:31 +02:00
Benjamin Bouvier
13f2c89e06 xtask: force --target-applies-to-host when running Clippy check
Without this, the configs from `.cargo/config.toml` were not read in CI
tasks, causing false positives when running Clippy on CI (i.e. there
were issues observed when compiling locally that were not found when
compiling remotely).

Not entirely sure why it's needed, because I'm seeing the issues when
I'm using `cargo xtask ci clippy` locally, with nothing changed.
2024-06-05 09:34:31 +02:00
Ivan Enderlin
d4df2624ff Merge pull request #3444 from surakin/encrypted-stickers
Expose new sticker source field (and drop url field)
2024-06-05 09:04:40 +02:00
Ivan Enderlin
37098bbb43 Merge pull request #3510 from maan2003/push-zluyyrrmtqpz
fix: bump deadpool-sync
2024-06-05 08:52:59 +02:00
Ivan Enderlin
1913d012ee Merge pull request #3509 from matrix-org/jplatte/unexpected-cfgs
Configure unexpected-cfgs via Cargo.toml instead of build scripts
2024-06-05 08:50:21 +02:00
maan2003
80ccbd045f fix: bump deadpool-sync 2024-06-05 03:18:53 +05:30
Jonas Platte
b73dbb4a55 Bump nightly version 2024-06-04 23:45:33 +02:00
Jonas Platte
02185f7034 Configure unexpected-cfgs via Cargo.toml instead of build scripts 2024-06-04 23:34:38 +02:00
Marco Antonio Alvarez
dadca42776 expose sticker source field
Signed-off-by: Marco Antonio Alvarez <surakin@gmail.com>

go back to old ruma rev
2024-06-04 15:18:04 +02:00
Benjamin Bouvier
5d549f1714 integration test: raise the sync time before considering it as stable
It turns out that the failure came when using the known room path in the
room preview: Alice knows about the room, but for some reason the client
didn't retrieve all the state events from the sliding sync proxy yet.

Before, the sync would be considered stable after 2 seconds. This is too
little, considering that events come from the proxy that listens to
events from synapse. Raising this threshold to 15 seconds should help
getting all the room information from the proxy, and thus get all the
information we expected in the client.
2024-06-04 14:57:26 +02:00
Benjamin Bouvier
77f0b6a4e2 pagination: don't hold onto the waited_for_initial_prev_token lock for too long
While this mutex is taken, in `oldest_token()` we can get a hold of the
RoomEvent mutex, making it so that the `waited_...` token covers the
critical region of room events.

Unfortunately, in `clear()`, we're taking these two locks in the
opposite order, implying that the room events critical region now
overlaps that of the `waited_...` lock.

The way to break the cycle is to keep the `waited_` token for as short
as possible.
2024-06-04 11:46:37 +02:00
Benjamin Bouvier
bffcb26e7d multiverse: add support for sending messages and {en|dis}abling the sending queue 2024-06-03 17:42:30 +02:00
Benjamin Bouvier
78608a1b9d sending queue: do a few renamings after the live review
Thanks @Hywan for the review comments!
2024-06-03 15:30:56 +02:00
Benjamin Bouvier
75aba1d17f clippy: declare victory over clippy
So as to not use sync mutexes across await points, we have to use an
async mutex, BUT it can't be immediately called in a wiremock responder,
so we need to shoe-horn a bit: create a new tokio runtime, which can
only be called from another running thread, etc. It's a bit ugly, but I
couldn't find another mechanism to block the responder from returning a
Response immediately; happy to change that anytime if there's a simpler
way.
2024-06-03 15:30:56 +02:00
Benjamin Bouvier
c5e8cb71b5 sending queue: add better logging for debug purposes 2024-06-03 15:30:56 +02:00
Benjamin Bouvier
a49b3a1b61 sending queue: remove spurious async 2024-06-03 15:30:56 +02:00
Benjamin Bouvier
0e8a707311 sending queue: add a global way to observe the enablement state
A client would require this to know that the sending queue has been
globally disabled, across all the rooms, otherwise they couldn't know
that it needs to be re-enabled later on.
2024-06-03 15:30:56 +02:00
Benjamin Bouvier
2cf36c7a5e sdk: add a sending queue for handling sending room events in the background
This implements the following features:

- enabling/disabling the sending queue at a client-wide granularity,
- one sending queue per room, that lives until the client is shutting
down,
- retrying sending an event three times, if it failed in the past, with
some exponential backoff to attempt to re-send,
- allowing to cancel sending an event we haven't sent yet.

fixup sdk
2024-06-03 15:30:56 +02:00
Benjamin Bouvier
001e88a60d sdk: add an optional RequestConfig to the SendMessageLikeEvent futures 2024-06-03 15:30:56 +02:00
Benjamin Bouvier
4ec34ad25d ffi: get rid of get_timeline_event_content_by_event_id
This can be equivalently retrieved using:

`get_timeline_event_by_event_id(event_id).content().as_message()?.content()`

As per the commit date, this is used in one place in both EXA and EXI,
so it seems fine to change the caller's call sites.

And this avoids one explicit call site of
`Timeline::item_by_event_id()`.
2024-06-03 15:28:17 +02:00
Ivan Enderlin
03b58ea1df Merge pull request #3491 from Hywan/feat-sdk-event-cache-pagination-through-update-2
feat(sdk): Add `RoomPagination::run_backwards(…, until)`, take 2
2024-06-03 10:28:49 +02:00
Ivan Enderlin
59924ea03e doc(sdk): Fix Control to ControlFlow. 2024-06-03 09:11:47 +02:00
Ivan Enderlin
b85c819414 Reapply "feat(sdk): Add RoomPagination::run_backwards(…, until)"
This reverts commit 392fd004d9.
2024-06-03 09:09:57 +02:00
Benjamin Bouvier
6012c7d98b chore: remove unused dependencies
Thanks cargo-machete.
2024-05-31 17:26:57 +02:00