Commit Graph

1230 Commits

Author SHA1 Message Date
Benjamin Bouvier
1da785e6cb fix(crypto): upload device keys *before* sending the keys signature during XSigning bootstrapping
There was a bug previously, that the cross-signing bootstrapping could include a signature for a device key that hadn't been uploaded yet.
This fixes it by returning a third (!) request in `bootstrap_cross_signing`, that must be sent as the second in order, and will upload
keys, if required.

Also tweaks documentation. Fixes #2749.
2023-10-27 16:22:24 +02:00
Benjamin Bouvier
631ab26d8b Rename some variables in crypto related to cross-signing bootstrapping 2023-10-27 16:22:24 +02:00
Jonas Platte
05a1021724 Use assert_let! instead of assert_matches! with bindings 2023-10-26 17:29:29 +02:00
Jonas Platte
a515bc8f03 ffi: Remove tokio::Runtime::block_on usage in async fn 2023-10-25 16:16:58 +02:00
Stefan Ceriu
570ef38de3 Remove unused anyhow import 2023-10-24 17:00:08 +02:00
Benjamin Bouvier
468337f026 Update bindings/matrix-sdk-ffi/src/session_verification.rs 2023-10-24 17:00:08 +02:00
Stefan Ceriu
040d095a04 Change the is_verified flag source to device.is_cross_signed_by_owner as theoretically the previous implementation was wrong 2023-10-24 17:00:08 +02:00
Stefan Ceriu
fa90269e7e Fixes vector-im/element-x-ios/issues/1868 - Incorrect is_verified flag after successfully running verification flow
- the inner user_identity isn't automatically updated when the flow finishes, needs to be fetched again from encryption
2023-10-24 17:00:08 +02:00
Timo
4933a50496 Add active calls to RoomInfo 2023-10-23 15:05:12 +02:00
Benjamin Bouvier
8bfcd20801 crypto: make Account not clonable and the Account in the cache optional 2023-10-20 17:04:40 +02:00
Jonas Platte
6d0ed67679 widget: Rename remaining "permissions" to capabilities
… a few uppercase Permissions were missed last time.
2023-10-20 13:28:53 +02:00
Jonas Platte
d5bda8147f ffi: Remove _blocking functions
Except for full_room_blocking, which is apparently noticably faster.
They were only added as a workaround for a UniFFI bug that has now been
fixed.
2023-10-19 07:56:06 +02:00
Jonas Platte
02a0916bc2 widget: Rename "permissions" to "capabilities"
… to match the postMessage JSON API.
2023-10-18 18:17:31 +02:00
Mauro Romito
5f0e5c7407 added the with_mentions method 2023-10-18 15:42:14 +02:00
Jonas Platte
de0543c2e2 widget: Rename settings#id to widget_id 2023-10-17 16:55:02 +02:00
Timo
7ee872c4bd Fix avatar url and display name in element call link generation
Signed-off-by: Timo K <toger5@hotmail.de>
Co-authored-by: Jonas Platte <jplatte@matrix.org>
2023-10-16 11:00:32 +02:00
Benjamin Bouvier
41a26e30e9 oidc: use sha2 to hash everything oidc-related
Hashes computed by `compute_session_hash` may be stored in the crypto store, and may or may not
be encrypted; make them slightly more secure by using a more secure hash. Also use sha2 for
the logged hashes that are useful for debugging OIDC issues.
2023-10-13 11:06:08 +02:00
Jonas Platte
735b0d2d24 ffi: Allow MessageType to contain arbitrary msgtype values, plus body
… allows the FFI type MessageLikeEventContent to hold custom msgtypes,
which is useful for notification.
Also allows sending custom msgtypes, as long as no fields other than the
msgtype itself and body are needed.
2023-10-13 10:06:07 +02:00
Jonas Platte
a6a4695dd4 ffi: Inline local variables in WidgetSettings conversion 2023-10-12 18:39:47 +02:00
Alfonso Grillo
f826999773 feature: send voice message API (#2697)
This PR adds a ffi binding for sending voice messages in the legacy format (before extensible events). It also makes minor changes in the `matrix-sdk` crate to accomodate this change.

* Add send_voice_message api

* Update ruma-events dependency

* Fix attachment info mapping

* Remove unstable dependency in attachment.rs

* Bump ruma-events

* Fix matrix-sdk Cargo.toml

* Fix formatting issues

* Refactor Voice case

* Remove clone from AttachmentInfo

* Remove duplicate code

* Remove unused imports

* Fix formatting issue

* Rename update function
2023-10-12 16:34:09 +00:00
Jonas Platte
4b98d24230 Upgrade UniFFI 2023-10-11 15:21:18 +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
Damir Jelić
c1d24aea90 Upgrade the deps for the store-encryption and crypto-ffi crates 2023-10-10 14:00:55 +02: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
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
Benjamin Bouvier
57b1442e1c crypto: rename ReadOnlyAccount to Account \o/ \o/ \o/ \o/ 2023-10-09 11:00:13 +02:00
Daniel Abramov
0726955678 widget: minor fixes in formatting, typos, etc 2023-10-09 10:55:48 +02:00
Timo
2120acabbb sdk: Add url creation to WidgetSettings
Signed-off-by: Timo K <toger5@hotmail.de>
2023-10-05 19:54:46 +02:00
Benjamin Bouvier
d8c2ad7693 ffi: use Timeline::send_single_receipt instead of Room::send_single_receipt for sending read receipts
The latter will always send a query, while the former will attempt to deduplicate sending a read receipt, if the event was already marked as read.
2023-10-05 16:59:28 +02:00
Benjamin Bouvier
1d01c32491 chore: remove unused FFI send_read_marker 2023-10-05 16:59:28 +02:00
Alfonso Grillo
aa1b871d00 ffi: Refine NotificationSettingsError type 2023-10-04 15:58:44 +02:00
Benjamin Bouvier
0d592e4051 chore: make Client::homeserver not async by changing the underlying kind of mutex
The mutex used for the `homeserver` field is very short-lived, so use a std mutex instead, which
makes a few methods sync instead of async.
2023-10-03 14:25:48 +02:00
Alfonso Grillo
08b3c0e47e Feature: add API for setting underride push rule's actions (#2644) 2023-10-03 10:08:17 +02:00
Matthew Hodgson
9ddef138c1 feat: support creating emotes (#2648)
* support creating emotes

adds an emote param to message_event_content_from_markdown and
message_event_content_from_html so that clients can create
m.room.message events with msgtype emote (on the assumption
that the msgtype returned in the RoomMessageEventContentWithoutRelation
is immutable, and so can't be overridden by the client)

* lint

* switch to separate methods per review feedback
2023-10-02 18:48:33 +02:00
Ivan Enderlin
f71a6fc738 feat(base): Latest event is represented by the new LatestEvent type.
This patch adds a new `LatestEvent` type. It wraps the
`SyncTimelineEvent` that was used before. The idea is to add more fields
onto this `LatestEvent` struct, but this patch starts easy by using
`LatestEvent` everywhere where it's required.
2023-10-02 09:49:56 +02:00
Valere
ab2f18df3b Add new API to request missing secrets (#2641) 2023-09-29 12:12:34 +02:00
Jonas Platte
cbb7b24cb5 Rewrite public widget API 2023-09-27 14:45:33 +02:00
Jonas Platte
ae524b3fa6 ffi: Use FFI's tokio runtime explicitly for acquire_permissions 2023-09-27 13:13:27 +02:00
Jonas Platte
956d5ef7e7 ffi: Update Room::edit to not make unnecessary network requests 2023-09-26 15:29:23 +02:00
Alfonso Grillo
b248aa9862 ffi: Add push notification support for unstable m.poll.start 2023-09-26 10:38:24 +02:00
Jonas Platte
f2c569440e ui: Remove transaction ID parameter on Timeline methods
There is no reason for it to be configurable in the high-level API,
since the timeline manages local echoes automatically.
2023-09-25 16:50:59 +02:00
Jonas Platte
cb8c71ad68 ffi: Add EventTimelineItem::can_be_replied_to 2023-09-25 11:26:51 +02:00
Jonas Platte
579f59c54b ffi: Update send_reply to not make unnecessary network requests
… and add Room::get_event_timeline_item_by_event_id so send_reply can be
called more easily by EX-iOS given its code structure.
2023-09-25 11:26:51 +02:00
Marco Romano
bd18c373fe Workaround uniffi kotlin bug with empty structs
Adds a dummy fuield to `UnstableVoiceContent`, otherwise uniffi
will generate an empty Kotlin data class which breaks compilation
(Kotlin data classes must have at least 1 field).
Upstream bug: https://github.com/mozilla/uniffi-rs/issues/1760
2023-09-21 14:28:55 +00:00
Ivan Enderlin
77d6c3144e Merge pull request #2581 from Hywan/feat-ffi-room-avatar-image-info 2023-09-21 12:24:02 +02:00
Ivan Enderlin
0989dd7fb7 feat(ui): Add the none filter
feat(ui): Add the `none` filter
2023-09-21 10:20:07 +02:00
Ivan Enderlin
7fc77a2d7e fix(ffi): RoomListItem::full_room is now async.
Because it creates a bug on iOS when using `RUNTIME.block_on` here.

This patch also adds `full_room_blocking` temporarily for Kotlin.
2023-09-21 09:35:16 +02:00
Ivan Enderlin
ce2bac6818 feat(ffi): Add RoomListEntriesDynamicFilterKind::None. 2023-09-21 09:32:12 +02:00
Jonas Platte
1a15802201 Upgrade Ruma 2023-09-20 14:19:06 +02:00
Jonas Platte
784171e261 ffi: Don't check original sender of message when editing
The timeline checks this already. The network request made for this was
wasteful and unnecessary.
2023-09-20 11:57:38 +02:00