Commit Graph

13223 Commits

Author SHA1 Message Date
Kévin Commaille d88437e707 Fix visibility of types
Signed-off-by: Kévin Commaille <zecakeh@tedomum.fr>
2023-10-11 12:00:09 +02:00
Kévin Commaille dae8c0a37f Update read receipt of prev event if visibility changed
Signed-off-by: Kévin Commaille <zecakeh@tedomum.fr>
2023-10-11 12:00:09 +02:00
Kévin Commaille d0f74a76d6 ui: Expose read receipts of hidden events on visible events
Signed-off-by: Kévin Commaille <zecakeh@tedomum.fr>
2023-10-11 12:00:09 +02:00
Kévin Commaille 54bbb05c22 ui: Rename receipt to new_receipt
Signed-off-by: Kévin Commaille <zecakeh@tedomum.fr>
2023-10-11 12:00:09 +02:00
Kévin Commaille 148c75120c ui: Move maybe_add_implicit_read_receipt as a method of TimelineInnerStateTransaction
Signed-off-by: Kévin Commaille <zecakeh@tedomum.fr>
2023-10-11 12:00:09 +02:00
Kévin Commaille aca6210b6b ui: Keep track of read receipts on all events
Not only event items

Signed-off-by: Kévin Commaille <zecakeh@tedomum.fr>
2023-10-11 12:00:09 +02:00
Benjamin Bouvier 1a56d6c0d8 fix: live-migrate LatestEvent data from the former format to the newer
#2587 introduced a breaking change in the serialized format of `RoomInfo`, changing the `event`
field format in particular, without a migration. As a result, this lead to users state stores
being invalidated for containing incorrect data, and thus being logged out.

This mitigates the issue by making sure that the LatestEvent type is either deserialized as its
newer format (aka `SerializedLatestEvent`) or its older format (aka `SyncTimelineEvent`). This
way, we maintain compatibility with the previous format. We always serialize to the new one, so
we'd only run this migration once.
2023-10-11 09:08:12 +00:00
Daniel Abramov 3567c9dc65 widget: move client into own module and split up 2023-10-11 09:50:58 +02:00
Daniel Abramov d8d136b330 widget: change signature of the ClientApi
Return `Self` and the channel to process incoming actions.
2023-10-11 09:50:58 +02:00
Daniel Abramov 5b92b0ac37 widget: move client into its own module 2023-10-11 09:50:58 +02:00
Damir Jelić c2bb76029a Rename the encrypt_with_iv method so it's clear that it also can decrypt 2023-10-10 18:15:45 +02:00
Damir Jelić 372e0d3d98 Secret storage support
Co-authored-by: Ivan Enderlin <ivan@mnt.io>
Co-authored-by: Denis Kasak <dkasak@termina.org.uk>
2023-10-10 18:15:45 +02:00
Jonas Platte 194c448047 ui: Update send_reply arguments
- `content` is now of type `RoomMessageEventContentWithoutRelation`,
  the relation was previously always overwritten if set
- `add_mentions` is now inferred from `content.mentions`
2023-10-10 17:14:55 +02:00
Richard van der Hoff 63fab7e292 Clean up duplicate/incomplete tracing 2023-10-10 14:28:06 +02:00
Richard van der Hoff 4e4077d6e0 Improve documentation on QrVerificationData (#2689)
I spent a while trying to figure out how all of this works.
2023-10-10 12:06:16 +00:00
Damir Jelić d62cf340c9 Pin reqwests to 0.11.20 2023-10-10 14:00:55 +02:00
Damir Jelić c1d24aea90 Upgrade the deps for the store-encryption and crypto-ffi crates 2023-10-10 14:00:55 +02:00
Damir Jelić 06bb81aaf2 fixup! Add a test ensuring that we didn't mess up our Device deserialization 2023-10-10 14:00:55 +02:00
Damir Jelić 235a8bd5ed Run cargo update for all the things 2023-10-10 14:00:55 +02:00
Damir Jelić 2fce44a16a Add a test ensuring that we didn't mess up our Device deserialization 2023-10-10 14:00:55 +02:00
Damir Jelić 97fe9614e5 Upgrade our pbkdf dependency 2023-10-10 14:00:55 +02:00
Damir Jelić cda0a5da13 Remove atomic from our deps 2023-10-10 14:00:55 +02:00
Jonas Platte 129a5e1acc ui: Wait for pagination token across multiple sync response notifs
… if wait_for_token flag is set for backwards-pagination.
2023-10-10 13:39:59 +02:00
Damir Jelić 04565378fa Only mark our own user identity as verified if it wasn't already 2023-10-10 13:04:09 +02:00
Damir Jelić 2843aef352 Ensure that the private cross-signing keys get persisted after invalidation 2023-10-10 13:04:09 +02:00
Damir Jelić 626df0b589 Test that the invalidated private cross-signing keys get correctly persisted 2023-10-10 13:04:09 +02:00
Damir Jelić 4918710cdc Add the ability to create a test IdentityManager with an arbitrary user ID 2023-10-10 13:04:09 +02:00
Kévin Commaille e674ccf5a4 Use timeline.items() instead of stream
Signed-off-by: Kévin Commaille <zecakeh@tedomum.fr>
2023-10-10 12:05:57 +02:00
Kévin Commaille d25acdf237 Remove is_empty variable
Signed-off-by: Kévin Commaille <zecakeh@tedomum.fr>
2023-10-10 12:05:57 +02:00
Kévin Commaille f7bf417996 ui: Test explicit read receipt ignored when implicit read receipt exists
Signed-off-by: Kévin Commaille <zecakeh@tedomum.fr>
2023-10-10 12:05:57 +02:00
Kévin Commaille e778316918 ui: Do not add explicit receipts if implicit receipt is newer
Should avoid users receipts appearing on two different events in the timeline

Signed-off-by: Kévin Commaille <zecakeh@tedomum.fr>
2023-10-10 12:05:57 +02:00
Kévin Commaille d03c255342 ui: Create ReadReceipts struct
Signed-off-by: Kévin Commaille <zecakeh@tedomum.fr>
2023-10-10 12:05:57 +02:00
Jonas Platte a88afd818b ui: Add more tracing events around back-pagination tokens 2023-10-09 17:21:52 +02:00
Daniel Abramov 880e918a5e widget: Add missing license headers 2023-10-09 14:55:58 +00:00
Benjamin Bouvier c64d3b4b7a Introduce a store transaction for Account (#2660)
This adds a new `StoreTransaction` type, that wraps a `StoreCache` and a `Store`. The idea is that it will allow write access to the `Store` (and maintains the cache at the same time), while the `Store::cache` method will only give read-only access to the store's content.

Another new data type is introduced, `PendingChanges`, that reflects `Changes` but for fields that are properly maintained in the `StoreCache` and that one can write in the `StoreTransaction`. In the future, it wouldn't be possible to use `save_pending_changes` from the outside of a `StoreTransaction` context.

The layering is the following:

- `Store` wraps the `DynCryptoStore`, contains a reference to a `StoreCache`.
- When read-only access is sufficient, one can get a handle to the cache with `Store::cache()`.
- When a write happens, then one can create a `StoreTransaction` (later, only one at a time will be allowed, by putting the `StoreCache` behind a `RwLock`; this has been deferred to not make the PR grow too much).
- Any field in the `StoreCache` will get a method to get a reference to the cached thing: it will either load from the DB if not cached, or return the previously cached value. 
- Any field that can be written to will get a method to get a mutable reference in the `StoreTransaction`: it will either load from the cache into a `PendingChanges` scratch pad, or return the scratchpad temporary value.
- When a `StoreTransaction::commit()` happens, fields are backpropagated into the DB *and* the cache. 

Then, this `StoreTransaction` is used to update a `ReadOnlyAccount` in multiple places (and usage of `ReadOnlyAccount` is minimized so as not to require a transaction or cache function call as much as possible). With this, the read-only account only exists transiently, and it's only stored long-term in the cache.

Followup PRs include:

- making the `ReadOnlyAccount` not cloneable
- remove inner mutability from the `ReadOnlyAccount`
- add a `RwLock` on the `StoreTransaction`

Part of https://github.com/matrix-org/matrix-rust-sdk/issues/2624 + https://github.com/matrix-org/matrix-rust-sdk/issues/2000.

---

* crypto: Replace some uses of `ReadOnlyAccount` with `StaticAccountData` and identify tests

* crypto: introduce `StoreTransaction` to modify a `ReadOnlyAccount`

* crypto: introduce `save_pending_changes`, aka `save_changes` v2

* crypto: Start using `StoreTransaction`s to save the account, get rid of `Store::save_account` + `Account::save`

* crypto: use `StoreTransaction` to save an account in `keys_for_upload`

* crypto: use `StoreTransaction` and the cache in more places

* crypto: remove `Account` from the `Changes` \o/

* crypto: remove last (test-only) callers of `Store::account()`

* crypto: move `ReadOnlyAccount` inside the cache only

* crypto: use `ReadOnlyAccount` and `Account` in fewer places

whenever we can use `StaticAccountData` in place.

* crypto: make tests rely less on OlmMachine

* crypto: Don't put the `ReadOnlyAccount` behind a RwLock just yet

+ clippy
2023-10-09 14:16:06 +00:00
Kévin Commaille 41de52b6b0 ui: Reimplement compare_events_positions using all timeline events
Signed-off-by: Kévin Commaille <zecakeh@tedomum.fr>
2023-10-09 12:13:03 +02:00
Kévin Commaille 155ec45a9e ui: Keep track of the order of all events in the Timeline
Signed-off-by: Kévin Commaille <zecakeh@tedomum.fr>
2023-10-09 12:13:03 +02:00
Ivan Enderlin 487f85b9e3 feat: Make latest_event faster regarding member profile
feat: Make `latest_event` faster regarding member profile
2023-10-09 11:41:32 +02:00
Ivan Enderlin 76ace82298 doc(ui): Fix a typo. 2023-10-09 11:22:43 +02:00
Ivan Enderlin a61bc77572 chore(base): Clean up. 2023-10-09 11:21:56 +02:00
Jonas Platte d216414608 ui: Make loop / continue comments less ambiguous 2023-10-09 11:16:03 +02:00
Jonas Platte 23390403b6 ui: Add more tracing to pagination 2023-10-09 11:16:03 +02:00
Jonas Platte d1ad16fbab ui: Document paginate_backwards_impl 2023-10-09 11:16:03 +02:00
Benjamin Bouvier 2a78b925e4 crypto: move all the Account methods in a single impl block 2023-10-09 11:00:13 +02:00
Benjamin Bouvier 57b1442e1c crypto: rename ReadOnlyAccount to Account \o/ \o/ \o/ \o/ 2023-10-09 11:00:13 +02:00
Benjamin Bouvier 1e9c05ad6f crypto: get rid of Account \o/ \o/ \o/ 2023-10-09 11:00:13 +02:00
Benjamin Bouvier 05d65e9b60 crypto: move methods from Account to ReadOnlyAccount 2023-10-09 11:00:13 +02:00
Benjamin Bouvier 850d25d8ec crypto: tweak a few code comments 2023-10-09 11:00:13 +02:00
Benjamin Bouvier 0b818fe4a5 crypto: use a Store in the DehydratedDevice data structure as it's sufficient 2023-10-09 11:00:13 +02:00
Benjamin Bouvier 03b4e87bd9 crypto: retrieve the StaticAccountData from the store in more places 2023-10-09 11:00:13 +02:00