Commit Graph

4916 Commits

Author SHA1 Message Date
Damir Jelić
9ef465fdf4 chore: Fix the formatting 2024-05-13 12:22:35 +02:00
Denis Kasak
11de0449fa Merge pull request from GHSA-9ggc-845v-gcgv
Avoid incorrect usage of private backup key
2024-05-13 10:07:10 +00:00
Ivan Enderlin
964553952d Merge pull request #3399 from matrix-org/stefan/invitesListCleanup
feat(ui): enable `room-list-with-unified-invites` by default, remove …
2024-05-13 11:51:10 +02:00
Ivan Enderlin
5c52014c4b Merge pull request #3386 from matrix-org/stefan/joinedRoomListFilter
feat(ui): add room list filter for excluding non-joined rooms
2024-05-13 11:24:13 +02:00
Stefan Ceriu
85d09c3c56 feat(ui): enable room-list-with-unified-invites by default, remove old invites sliding sync list. 2024-05-13 11:55:38 +03:00
Ivan Enderlin
c0924c87af feat(sdk): Introduce linked_chunk::Updates
feat(sdk): Introduce `linked_chunk::Updates`
2024-05-12 17:42:29 +02:00
Kévin Commaille
733665ddcc ui: Expose message mentions
Signed-off-by: Kévin Commaille <zecakeh@tedomum.fr>
2024-05-11 10:53:52 +02:00
Valere
df5e8e724e Review: better comments
Co-authored-by: Denis Kasak <dkasak@termina.org.uk>
Signed-off-by: Valere <bill.carson@valrsoft.com>
2024-05-10 15:49:20 +02:00
Valere
a7cc3777d1 Review: better comment
Co-authored-by: Denis Kasak <dkasak@termina.org.uk>
Signed-off-by: Valere <bill.carson@valrsoft.com>
2024-05-10 15:49:02 +02:00
Kévin Commaille
4724115e8d chore: Fix docs warning
Signed-off-by: Kévin Commaille <zecakeh@tedomum.fr>
2024-05-10 12:16:42 +02:00
Kévin Commaille
99ae06be68 chore: Fix cfg options
Cargo nightly now checks whether a cfg option exists.
We need to declare the custom
options we use
and fix those that are wrong.

Signed-off-by: Kévin Commaille <zecakeh@tedomum.fr>
2024-05-10 11:34:59 +02:00
Kévin Commaille
787b2d31cd chore: Fix warnings during compilation
cargo says that default_features will not be supported anymore in 2024 edition

Signed-off-by: Kévin Commaille <zecakeh@tedomum.fr>
2024-05-10 11:32:05 +02:00
Damir Jelić
fac5ba5bae chore(crypto): Refactor the PK signing subkey constructors
This makes the public key fields private to ensure that we don't
accidentally swap them out. It also moves the construction of the
subkeys into the master key type.
2024-05-09 18:03:55 +02:00
Damir Jelić
c57d2c68a1 fixup! chore(crypto): Refactor the cross-signing key wrappers 2024-05-09 17:41:32 +02:00
Damir Jelić
6b1ef484f2 chore(crypto): Refactor the cross-signing key wrappers
Since the master/self-signing/user-signing public key types are used for
public user identities as well as for the private key type we have, and
we'd like to sign the public key types it makes sense that the types
itself aren't using an Arc.

Let's instead put the Arc inside the user identity structs.

This will allow us later on to more easily sign the public key types.
2024-05-09 17:41:32 +02:00
Damir Jelić
aeb85ba836 chore: Add a better debug implementation for the backup recover/decryption key 2024-05-09 17:40:51 +02:00
Ivan Enderlin
1f26822a64 chore(sdk): Split linked_chunk into 2 modules. 2024-05-08 14:47:45 +02:00
Ivan Enderlin
44a78ba9f6 chore(sdk): Thanks Clippy. 2024-05-08 13:58:49 +02:00
Ivan Enderlin
1493dc2c6a chore(sdk): Remove the LinkedChunk prefix from type names. 2024-05-08 13:45:45 +02:00
Ivan Enderlin
9531a4041e feat(sdk): Allow LinkedChunkUpdatesInner to have multiple readers.
This patch removes the notion of `take` vs. `peek` from
`LinkedChunkUpdatesInner` and widens the problem to a more general
approach: `LinkedChunkUpdatesInner` must support multiple readers, not
only two (`take` was the first reader, `peek` was the second reader,
kind of).

Why do we need multiple readers? `LinkedChunkUpdates::take` is
clearly the first reader, it's part of the public API. But the private
API needs to read the updates too, without consuming them, like
`LinkedChunkUpdatesSubscriber`. `peek` was nice for that, but it's
possible to have multiple `LinkedChunkUpdatesSubscriber` at the same
time! Hence the need to widen the approach from 2 readers to many
readers.

This patch introduces a `ReaderToken` to identify readers. The last
indexes are now all stored in a `HashMap<ReaderToken, usize>`. The rest
of the modifications are the consequence of that.

The test `test_updates_take_and_peek` has been entirely rewritten to be
`test_updates_take_and_garbage_collector` where it tests 2 readers and
see how the garbage collector reacts to that.
2024-05-08 13:45:45 +02:00
Stefan Ceriu
1ce27d6eec feat(ui): add room list filter for excluding non-joined rooms 2024-05-08 12:48:14 +03:00
Ivan Enderlin
73ae1cc6da feat(sdk): Add LinkedChunkUpdatesSubscriber.
This patch implements `LinkedChunkUpdates::subscribe` and
`LinkedChunkUpdateSubscriber`, which itself implements `Stream`.

This patch splits `LinkedChunkUpdates` into `LinkedChunkUpdatesInner`,
so that the latter can be shared with `LinkedChunkUpdatesSubscriber`.
2024-05-08 09:23:20 +02:00
Valere
d0776819c7 Review: Add assert error message
Co-authored-by: Damir Jelić <poljar@termina.org.uk>
Signed-off-by: Valere <bill.carson@valrsoft.com>
2024-05-07 14:43:15 +02:00
Valere
4e9edcb0db Review: better comment
Co-authored-by: Damir Jelić <poljar@termina.org.uk>
Signed-off-by: Valere <bill.carson@valrsoft.com>
2024-05-07 14:42:52 +02:00
Valere
e3dc094be4 Add minimal reproducing test 2024-05-07 10:20:19 +02:00
Valere
f4772c9b0e Add FIXME comment 2024-05-07 10:20:08 +02:00
Ivan Enderlin
76210686c4 feat(sdk): Implement Clone on LinkedChunkUpdate.
`LinkedChunkUpdate` implements `Clone` if and only if `Item` and `Gap`
both implement `Clone`.
2024-05-06 22:22:32 +02:00
Ivan Enderlin
3a00271af0 chore(sdk): Hmmmm. 2024-05-06 20:15:35 +02:00
Ivan Enderlin
d6915793c1 feat(sdk) Add the LinkedChunkUpdates::peek.
This patch adds the `LinkedChunkUpdates::peek` method. This is
a new channel to read the updates without consuming them, like
`LinkedChunkUpdates::take` does.

The complexity is: when do we clear/drop the updates then? We don't
want to keep them in memory forever. Initially `take` was clearing
the updates, but now that we can read them with `peek` too, who's
responsible to clear them? Enter `garbage_collect`. First off,
we already need to maintain 2 index, resp. `last_taken_index` and
`last_peeked_index` so that `take` and `peek` don't return already
returned updates. They respectively know the index of the last update
that has been read. We can use this information to know which updates
must be garbage collected: that's all updates below the two index.
Tadaa. Simple. The only _drawback_ (if it can be considered as such)
is that the garbage collection happens on the next call to `take` or
`peek` (because of the borrow checker). That's not really a big deal in
practise. We could make it happens immediately when calling `take` or
`peek` but it needs more pointer arithmetic and a less straighforward
code.
2024-05-06 20:13:42 +02:00
Ivan Enderlin
9e2e28d57a feat(sdk) Change the update history from a Vec<T> to a new LinkedChunkUpdates type.
This patch updates the `LinkedChunk::update_history` field from
a simple `Vec<LinkedChunkUpdate<Item, Gap>>` type to the new
`LinkedChunkUpdates<Item, Gap>` type (note the plural).

This is going to be helpul for the next patches.
2024-05-06 14:22:51 +02:00
Denis Kasak
60017241b2 Tweak log messages when rejecting devices (DeviceKeys structs) received from the server.
Preferring to use "reject" wording rather than "failed to
create/update". The latter can be easily misinterpreted as a failure of
the local client to create an entirely new device from scratch, rather
than refusal to instantiate a new local device representation of an
(invalid) device definition received from the server.
2024-05-03 14:08:36 +02:00
Denis Kasak
03fe9feb69 docs: Expand docs for the DeviceKeys struct. 2024-05-03 14:08:36 +02:00
Damir Jelić
6f2d8e0e50 chore: Fix some clippy warnings 2024-05-02 17:12:19 +02:00
Damir Jelić
56aa86da8b chore: Depend on a released version of mas-oidc-client 2024-05-02 17:12:19 +02:00
Ivan Enderlin
67e2842f84 feat(sdk): Introduce LinkedChunkUpdate
feat(sdk): Introduce `LinkedChunkUpdate`
2024-05-02 14:46:19 +02:00
Ivan Enderlin
443647a1ba feat(sdk): Make update history of LinkedChunk optional.
This patch makes the `LinkedChunk::update_history` field optional,
so that it doesn't require the user to drain it to avoid eating the
universe.

The `new` constructor disabled the update history, the
`new_with_update_history` enables it.
2024-05-02 14:30:19 +02:00
Ivan Enderlin
b9ea6ff300 chore(sdk): Rename LinkedChunkLinks to LinkedChunkEnds. 2024-05-02 14:30:19 +02:00
Ivan Enderlin
c219c727bb feat(sdk) Remove LinkedChunkListener.
This patch is a turn around about the `LinkedChunkListener`. Many
patches have been removed because `LinkedChunkListener` needed to
support I/O, so errors and async code. The whole code was affected by
that, resulting in a complex API. The idea of this patch is to decoupled
this. Here is how.

First off, `LinkedChunkListener` is removed. So it's one less generic
parameter on `LinkedChunk`. It's also one less trait, so less
implementations.

Second, now `LinkedChunk` accumulates/collects all “updates” under the
form of a new enum `LinkedChunkUpdate`. These updates can be read with
`LinkedChunk::updates(&mut self) -> &Vec<LinkedChunkUpdate>`. The reader
can simply read them, or even drain them. The reader is responsible
to handle these updates and to dispatch them in a storage or whatever.
`LinkedChunk` is no longer responsible to do that, removing the need to
support errors and to be async.

Third, the simplification has led to an optimisation by introducing a
new type `LinkedChunkLinks`. The documentation explains what it does
and why it was needed. The benefit of this type is: it doesn't increase
the size of `LinkedChunk`, but it simplifies the code: no more `Arc`,
no more `Mutex` (it was required because with I/O and async), no more
borrow checker trick, and the code stays as safe as before.
2024-05-02 14:30:19 +02:00
Ivan Enderlin
db0f9b19be feat(sdk) LinkedChunkError is a real error now. 2024-05-02 14:30:19 +02:00
Ivan Enderlin
343416653d feat(sdk): Create LinkedChunkListener.
This patch creates the `LinkedChunkListener` trait.

This patch also updates `LinkedChunk` to be able to use a
`LinkedChunkListener`.
2024-05-02 14:30:19 +02:00
Ivan Enderlin
17b3cb6b31 fix(store-encryption): Remove the displaydoc dependency
fix(store-encryption): Remove the `displaydoc` dependency
2024-05-02 09:41:43 +02:00
Ivan Enderlin
f8a6f90664 Merge pull request #3371 from matrix-org/bnjbvr/ansi-pedantic-sync-builder
tests: rename ev_builder to sync_builder + add test_ prefix to test functions
2024-05-02 09:36:00 +02:00
Ivan Enderlin
8ac51c19f5 Merge pull request #3369 from matrix-org/bnjbvr/get-rid-of-notificationclientbuilder
notification client: get rid of builder
2024-05-02 09:34:32 +02:00
Ivan Enderlin
ad2e8336f6 fix(store-encryption): Remove the displaydoc dep.
This patch removes the `displaydoc` dependency. Why?

1. It creates a warning in rustc nightly:

```
warning: non-local `impl` definition, they should be avoided as they go against expectation
  --> crates/matrix-sdk-store-encryption/src/lib.rs:49:17
   |
49 | #[derive(Debug, Display, thiserror::Error)]
   |                 ^^^^^^^
   |
   = help: move this `impl` block outside the of the current constant `_DERIVE_Display_FOR_Error`
   = note: an `impl` definition is non-local if it is nested inside an item and may impact type checking outside of that item. This can be the case if neither the trait or the self type are at the same nesting level as the `impl`
   = note: one exception to the rule are anon-const (`const _: () = { ... }`) at top-level module and anon-const at the same nesting as the trait or type
   = note: this lint may become deny-by-default in the edition 2024 and higher, see the tracking issue <https://github.com/rust-lang/rust/issues/120363>
   = note: the derive macro `Display` may come from an old version of the `displaydoc` crate, try updating your dependency with `cargo update -p displaydoc`
   = note: `#[warn(non_local_definitions)]` on by default
   = note: this warning originates in the derive macro `Display` (in Nightly builds, run with -Z macro-backtrace for more info)
```

2. `thiserror` is already used, which seems to provide a similar issue.
3. That's less dependency, and less proc-macro, which will improve the
   compilation time in general.
2024-05-02 09:27:17 +02:00
Benjamin Bouvier
f997256c73 ffi: revert a few methods back to sync
And sprinkle useful comments here and there.
2024-05-01 14:32:38 +02:00
Benjamin Bouvier
dedfc2649a ffi: get rid of name(), and use the computed_display_name() everywhere
This should make it more regular, in all the places, to use the same
string:
- Room
- RoomListItem
- RoomInfo
2024-05-01 14:32:38 +02:00
Benjamin Bouvier
90bed18415 ffi: make the name method sync again
Also:

- rename `display_name` to `computed_display_name` in several places,
and reflect that change into a few callers
- simplify slightly the `computed_display_name()` method
2024-05-01 14:32:38 +02:00
Benjamin Bouvier
a3061eb39a ffi: make RoomListItem::is_direct sync again
And comment why some methods it's calling are async under the hood.
2024-05-01 14:32:38 +02:00
Benjamin Bouvier
f69db1d169 notification client(bugfix): don't filter out the notification if we couldn't compute push actions with /context
This is in line with what the other method using sliding sync does. This
wasn't tested before, because this required `filter_by_push_rules()` to
be enabled in the notification client; now that it's the default, the
test revealed the bug, and so it could be fixed.
2024-05-01 13:13:14 +02:00
Benjamin Bouvier
0ba4e42161 notification client: get rid of builder
The builder had only one meaningful method, `filter_by_push_rules`,
which was always called by the applications — and in fact should always
be true. It was designed as an extra method because it was experimental
at the time, but it's stabilized sufficiently that we can enable this
behavior by default now, considering that a notification that is not
wanted by the user shouldn't be kept, to respect their intent. (This is
in the UI crate, which is opinionated, so it's fine to assume such
intents by design.)
2024-05-01 13:13:14 +02:00