Commit Graph

8988 Commits

Author SHA1 Message Date
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
Richard van der Hoff
b029519248 utd hook: fix re-reporting of late-decrypted events (#3480)
If an event cannot be decrypted after a grace period, it is reported to the application (and thence Posthog) as a UTD event. Currently, if it is then successfully decrypted, the event is then re-reported as a "late decryption".

This does not match the expected behaviour in Posthog - an event is *either* a UTD, or a late decryption; it makes no sense for it to be both. This PR fixes the problem.

I've attempted to make the commits sensible, but I'm not entirely sure I've succeeded. The tests do pass after each commit, though. The interesting change itself is somewhere in the middle; there is non-functional groundwork before and cleanup afterwards.

---

* ui: Factor out UTD report code to a closure

For now, this doesn't help much, but in future there will be more logic here,
and it helps reduce the repetition between the delay and no-delay cases.

* ui: Convert UtdHookManager::pending_delayed to a HashMap

* ui: Store decryption time in `UtdHookManager::pending_delayed`

This is a step on getting rid of `known_utds`

* ui: Fix re-reporting of late decryptions

This fixes the problem where a message that was previously reported as a UTD,
and was then subsequently successfully decrypted, is then re-reported as a late
decryption. This artificially inflated the UTD metrics.

We do this by checking the `pending_delayed` list in `on_late_decrypt`, instead
of the `known_utds` list. There is some associated reordering of code to get
the locking right.

* ui: Remove unused "utd report time" from `UtdHookManager::known_utds`

* ui: Replace `UtdHookManager::known_utds` with `reported_utds`

Keep a list of the UTDs we've actually reported, rather than the union of those
we've reported together with those we might report in a while.

I find this much easier to reason about.

* Address minor review comments

* Reinstate assertion in UTD hook tests

* Reinstate `known_utds`
2024-05-31 14:24:38 +02:00
Stefan Ceriu
61440c3561 ffi: enable panic logging for all supported platforms not only android 2024-05-31 09:06:24 +02:00
Jonas Platte
9c4e547f5a ci: Error if coverage report files are not found 2024-05-30 20:22:47 +02:00
Jonas Platte
fa3db13cec ci: Update coverage workflows to use the right file 2024-05-30 20:22:47 +02:00
Jonas Platte
eff57ad483 ci: Use one artifact for all coverage files
Instead of three separate artifacts.
2024-05-30 20:22:47 +02:00
Jonas Platte
2c964b07ab ci: Fix bash syntax in last code_coverage job step
It was trying to execute `upload_coverage.yml` before.
2024-05-30 20:22:47 +02:00
Jonas Platte
8c5d60e539 ci: Normalize indentation in upload_coverage.yml 2024-05-30 20:22:47 +02:00
Jonas Platte
63d4b758f8 ci: Only run upload_coverage if coverage workflow succeeded 2024-05-30 20:22:47 +02:00
Jonas Platte
7876c37715 Fix trigger condition for new upload_coverage workflow 2024-05-30 15:25:41 +02:00
Damir Jelić
29f29e981e chore: Go back to depending on Ruma from the Ruma repo 2024-05-30 15:12:45 +02:00
Kévin Commaille
2163b282b5 sdk: Add method to request user identity from homeserver (#3469)
Signed-off-by: Kévin Commaille <zecakeh@tedomum.fr>
2024-05-30 14:40:21 +02:00
Jonas Platte
40dc706270 Split codecov uploads into a separate workflow
… which runs in the context of the main repo even for PRs, and can be
retried individually without rerunning coverage collection.
2024-05-30 13:53:49 +02:00
Hubert Chathi
0c97c85aea add tests for unknown properties in device keys 2024-05-30 12:16:07 +02:00
Kévin Commaille
0db486b511 crypto: Add SasState::Created variant
To differentiate the SAS state between the party
that sent the verification start and the party that received it.

Signed-off-by: Kévin Commaille <zecakeh@tedomum.fr>
2024-05-30 12:09:46 +02:00