Commit Graph

8968 Commits

Author SHA1 Message Date
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
Stefan Ceriu
7551d87384 feat: add support for m.call.notify events in the timeline and as a last room message 2024-05-30 11:27:30 +02:00
Damir Jelić
3ac598666a bindings: Remove the InvalidQrCode error variant for the QR login error type. (#3481)
We have a separate error for the QR code decoding method.
2024-05-29 14:40:22 +02:00
Damir Jelić
1380af4f00 bindings: Even more precise errors for the QR code login 2024-05-29 13:45:55 +02:00
Damir Jelić
ab08f5e095 bindings(qr): Add an error variant for when the other device is not signed in 2024-05-29 13:45:55 +02:00
Damir Jelić
59d1f349b5 bindings: Expose the method to log in the client using a QR code
Co-authored-by: Benjamin Bouvier <public@benj.me>
2024-05-29 08:59:23 +02:00
Damir Jelić
3dbf8a07bd bindings: Move the OIDC metadata validation method into a TryInto method 2024-05-29 08:59:23 +02:00
Benjamin Bouvier
392fd004d9 Revert "feat(sdk): Add RoomPagination::run_backwards(…, until)" 2024-05-28 18:30:43 +02:00
Ivan Enderlin
72314f1014 feat(sdk): Add RoomPagination::run_backwards(…, until)
feat(sdk): Add `RoomPagination::run_backwards(…, until)`
2024-05-28 16:03:17 +02:00
Ivan Enderlin
9a1de1d9e8 test(sdk): Improve tests around RoomPagination::run_backwards. 2024-05-28 15:43:01 +02:00
Damir Jelić
7dd08c3b81 Add an example for the QR code login 2024-05-28 12:43:49 +02:00
Damir Jelić
e6dc24a914 feat: Add support to log in using a QR code
This implements one part of MSC4108[1], it implements the case where the
new device scans the QR code.

[1]: https://github.com/matrix-org/matrix-spec-proposals/pull/4108
2024-05-28 12:43:49 +02:00
Damir Jelić
05f9f85d2d Make errors public 2024-05-28 12:43:49 +02:00
Damir Jelić
96c5515b04 Add a method to ensure device keys are uploaded 2024-05-28 12:43:49 +02:00
Damir Jelić
e94b40a75f chore: Add the import secrets bundle method 2024-05-28 12:43:49 +02:00
Damir Jelić
dc60c1ee10 chore: Allow setting a custom vodozemac account 2024-05-28 12:43:49 +02:00
Damir Jelić
3e6347cd48 chore: Create a subdirectory for authentication 2024-05-28 12:43:49 +02:00
Ivan Enderlin
7377971da8 test(sdk): Ensure that until can trigger multiple iterations.
This patch adds a test for `until` when it returns
`ControlFlow::Continue` multiple times instead of `ControlFlow::Break`
immediately.
2024-05-28 11:34:05 +02:00
Ivan Enderlin
13df5d9db8 feat(sdk): Add TimelineHasBeenResetWhilePaginating.
This patch adds a new argument to the `until` argument closure of
`RoomPagination::run_backwards`: `timeline_has_been_reset`, which
designates when the timeline has been reset.

A test has been updated accordingly.
2024-05-28 11:32:24 +02:00
Ivan Enderlin
664a64b3f3 feat(sdk): Improve RoomEventCacheUpdate (#3471)
* chore(sdk): Rename `RoomEventCacheUpdate::UpdateReadMarker`.

This patch renames `RoomEventCacheUpdate::UpdateReadMarker` to
`ReadMarker`. The `Update` prefix is already part of the enum name.

* feat(sdk): Rename `RoomEventCacheUpdate::ReadMarker::event_id` to `move_to`.

This patch renames `RoomEventCacheUpdate::ReadMarker::event_id` to
`ReadMarker::move_to` as I feel like it conveys a better semantics.

* feat(sdk): Extract `RoomEventCacheUpdate::Append::ambiguity_changes`.

This patch extracts `RoomEventCacheUpdate::Append::ambiguity_changes`
into a new variant `RoomEventCacheUpdate::Members { ambiguity_changes }
`.

This patch also creates a new private
`RoomEventCacheInner::send_grouped_updates_for_events` method to ensure
the updates are sent in a particular order.

* feat(sdk): Rename `RoomEventCacheUpdate::Append`.

This patch renames `RoomEventCacheUpdate::Append` to `SyncEvents`. The
field `events` is renamed `timeline`.

This patch also renames some variables to clarify the code and to match
the renamings in `RoomEventCacheUpdate`.

* feat(sdk): Rename `RoomEventCacheUpdate::ReadMarker` and `Members`.

This patch renames `ReadMarker { move_to: … }` to `MoveReaderMarkerTo
{ event_id: … }`.

This patch also renames `Members` to `UpdateMembers`.

Finally, this patch renames some other variables to avoid clashes with
terminology in `matrix_sdk_ui`.

* feat(sdk): Split `RoomEventCacheUpdate::SyncEvents`.

This patch splits `RoomEventCacheUpdate::SyncEvents` into 2 new variants:
`AddTimelineEvents` and `AddEphemeralEvents`.

This patch takes this opportunity to update `matrix_sdk_ui::timeline`
a little bit too. `handle_sync_events` is renamed
`handle_ephemeral_events`, and the `SyncTimelineEvent` argument is
removed: it's possible to use `add_events_at` directly to handle the
`SyncTimelineEvent`s.

* fix(sdk): Do not send `RoomEventCacheUpdate` if values are empty.

This patch prevents sending useless `RoomEventCacheUdpate` if their
respective values are empty.

* chore(ui): Update a log message.

* Apply suggestions from code review

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-05-28 09:26:38 +00:00
Ivan Enderlin
6c90f7aaff feat(sdk): Add RoomPagination::run_backwards(…, until).
This patch adds a new argument to `RoomPagination::run_backwards`:
`until`. It becomes:

    pub async fn run_backwards<F, B, Fut>(&self,
        batch_size: u16,
        mut until: F
    ) -> Result<B>
    where
        F: FnMut(BackPaginationOutcome) -> Fut,
        Fut: Future<Output = ControlFlow<B, ()>>,

The idea behind `until` is to run pagination _until_ `until` returns
`ControlFlow::Break`, otherwise it continues paginating.

This is useful is many scenearii (cf. the documentation). This is
also and primarily the first step to stop adding events directly from
the pagination, and starts adding events only and strictly only from
`event_cache::RoomEventCacheUpdate` (again, see the `TODO` in the
documentation). This is not done in this patch for the sake of ease
of review.
2024-05-28 10:55:13 +02:00