Skip to content

Commit 61312e5

Browse files
committed
Merge branch 'main' into release-matrix-sdk-crypto-js-v0.1.0-alpha.8
2 parents 8ba80fc + 8f332fd commit 61312e5

File tree

15 files changed

+167
-164
lines changed

15 files changed

+167
-164
lines changed

Cargo.lock

Lines changed: 9 additions & 9 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,8 @@ eyeball = "0.6.0"
3232
eyeball-im = "0.2.0"
3333
futures-util = { version = "0.3.26", default-features = false, features = ["alloc"] }
3434
http = "0.2.6"
35-
ruma = { git = "https://github.com/ruma/ruma", rev = "0143bd9b9f5dcfcaa835afb76f342c12f014f945", features = ["client-api-c", "compat-user-id"] }
36-
ruma-common = { git = "https://github.com/ruma/ruma", rev = "0143bd9b9f5dcfcaa835afb76f342c12f014f945" }
35+
ruma = { git = "https://github.com/ruma/ruma", rev = "54a4223caa1c1052464ecdba0f1e08f126e07bcd", features = ["client-api-c", "compat-user-id"] }
36+
ruma-common = { git = "https://github.com/ruma/ruma", rev = "54a4223caa1c1052464ecdba0f1e08f126e07bcd" }
3737
once_cell = "1.16.0"
3838
serde = "1.0.151"
3939
serde_html_form = "0.2.0"

bindings/matrix-sdk-crypto-js/CHANGELOG.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
# v0.1.0-alpha.8
22

3-
- Make `unused_fallback_keys` as optional in `Machine.receive_sync_changes`
3+
- `importCrossSigningKeys`: change the parameters to be individual keys
4+
rather than a `CrossSigningKeyExport` object.
5+
- Make `unused_fallback_keys` optional in `Machine.receive_sync_changes`
46

57
# v0.1.0-alpha.7
68

bindings/matrix-sdk-crypto-js/scripts/build.sh

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,11 @@ cd $(dirname "$0")/..
1919
RUSTFLAGS='-C opt-level=z' WASM_BINDGEN_WEAKREF=1 wasm-pack build --target nodejs --scope matrix-org --out-dir pkg "${WASM_PACK_ARGS[@]}"
2020

2121
# Convert the Wasm into a JS file that exports the base64'ed Wasm.
22-
echo "module.exports = \`$(base64 pkg/matrix_sdk_crypto_js_bg.wasm)\`;" > pkg/matrix_sdk_crypto_js_bg.wasm.js
22+
{
23+
printf 'module.exports = `'
24+
base64 < pkg/matrix_sdk_crypto_js_bg.wasm
25+
printf '`;'
26+
} > pkg/matrix_sdk_crypto_js_bg.wasm.js
2327

2428
# In the JavaScript:
2529
# 1. Strip out the lines that load the WASM, and our new epilogue.

bindings/matrix-sdk-crypto-js/src/machine.rs

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -397,11 +397,11 @@ impl OlmMachine {
397397

398398
/// Export all the private cross signing keys we have.
399399
///
400-
/// The export will contain the seed for the ed25519 keys as a
401-
/// unpadded base64 encoded string.
400+
/// The export will contain the seeds for the ed25519 keys as
401+
/// unpadded base64 encoded strings.
402402
///
403-
/// This method returns None if we don’t have any private cross
404-
/// signing keys.
403+
/// Returns `null` if we don’t have any private cross signing keys;
404+
/// otherwise returns a `CrossSigningKeyExport`.
405405
#[wasm_bindgen(js_name = "exportCrossSigningKeys")]
406406
pub fn export_cross_signing_keys(&self) -> Promise {
407407
let me = self.inner.clone();
@@ -413,12 +413,22 @@ impl OlmMachine {
413413

414414
/// Import our private cross signing keys.
415415
///
416-
/// The export needs to contain the seed for the ed25519 keys as
417-
/// an unpadded base64 encoded string.
416+
/// The keys should be provided as unpadded-base64-encoded strings.
417+
///
418+
/// Returns a `CrossSigningStatus`.
418419
#[wasm_bindgen(js_name = "importCrossSigningKeys")]
419-
pub fn import_cross_signing_keys(&self, export: store::CrossSigningKeyExport) -> Promise {
420+
pub fn import_cross_signing_keys(
421+
&self,
422+
master_key: Option<String>,
423+
self_signing_key: Option<String>,
424+
user_signing_key: Option<String>,
425+
) -> Promise {
420426
let me = self.inner.clone();
421-
let export = export.inner;
427+
let export = matrix_sdk_crypto::store::CrossSigningKeyExport {
428+
master_key,
429+
self_signing_key,
430+
user_signing_key,
431+
};
422432

423433
future_to_promise(async move {
424434
Ok(me.import_cross_signing_keys(export).await.map(olm::CrossSigningStatus::from)?)

bindings/matrix-sdk-ffi/src/api.udl

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,10 @@ callback interface NotificationDelegate {
88
void did_receive_notification(NotificationItem notification);
99
};
1010

11+
interface AuthenticationService {};
12+
interface Span {};
13+
interface NotificationService {};
14+
1115
dictionary NotificationItem {
1216
TimelineEvent event;
1317
string room_id;
@@ -18,6 +22,8 @@ dictionary NotificationItem {
1822
boolean is_noisy;
1923
boolean is_direct;
2024
boolean is_encrypted;
25+
boolean is_read;
26+
u64 timestamp;
2127
};
2228

2329
interface TimelineEvent {};

bindings/matrix-sdk-ffi/src/authentication_service.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ use zeroize::Zeroize;
1111
use super::{client::Client, client_builder::ClientBuilder, RUNTIME};
1212
use crate::error::ClientError;
1313

14-
#[derive(uniffi::Object)]
1514
pub struct AuthenticationService {
1615
base_path: String,
1716
passphrase: Option<String>,

bindings/matrix-sdk-ffi/src/notification_service.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,9 @@ pub struct NotificationItem {
1818
pub is_noisy: bool,
1919
pub is_direct: bool,
2020
pub is_encrypted: bool,
21+
pub is_read: bool,
22+
23+
pub timestamp: u64,
2124
}
2225

2326
impl NotificationItem {
@@ -45,13 +48,14 @@ impl NotificationItem {
4548
is_noisy,
4649
is_direct: room.is_direct().await?,
4750
is_encrypted: room.is_encrypted().await?,
51+
is_read: notification.read,
52+
timestamp: notification.ts.0.into(),
4853
};
4954
Ok(item)
5055
}
5156
}
5257

5358
#[allow(dead_code)]
54-
#[derive(uniffi::Object)]
5559
pub struct NotificationService {
5660
base_path: String,
5761
user_id: String,

bindings/matrix-sdk-ffi/src/tracing.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,6 @@ fn span_or_event_enabled(callsite: &'static DefaultCallsite) -> bool {
9595
}
9696
}
9797

98-
#[derive(uniffi::Object)]
9998
pub struct Span(tracing::Span);
10099

101100
#[uniffi::export]

crates/matrix-sdk-base/src/client.rs

Lines changed: 29 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ use ruma::{
5454
MilliSecondsSinceUnixEpoch, OwnedUserId, RoomId, UInt, UserId,
5555
};
5656
use tokio::sync::RwLock;
57-
use tracing::{debug, info, trace, warn};
57+
use tracing::{debug, info, instrument, trace, warn};
5858

5959
use crate::{
6060
deserialized_responses::{AmbiguityChanges, MembersResponse, SyncTimelineEvent},
@@ -297,6 +297,7 @@ impl BaseClient {
297297
}
298298

299299
#[allow(clippy::too_many_arguments)]
300+
#[instrument(skip_all, fields(room_id = ?room_info.room_id))]
300301
pub(crate) async fn handle_timeline(
301302
&self,
302303
room: &Room,
@@ -438,6 +439,7 @@ impl BaseClient {
438439
Ok(timeline)
439440
}
440441

442+
#[instrument(skip_all, fields(room_id = ?room_info.room_id))]
441443
pub(crate) fn handle_invited_state(
442444
&self,
443445
events: &[Raw<AnyStrippedStateEvent>],
@@ -467,6 +469,7 @@ impl BaseClient {
467469
changes.stripped_state.insert(room_info.room_id().to_owned(), state_events);
468470
}
469471

472+
#[instrument(skip_all, fields(room_id = ?room_info.room_id))]
470473
pub(crate) async fn handle_state(
471474
&self,
472475
events: &[Raw<AnySyncStateEvent>],
@@ -478,21 +481,19 @@ impl BaseClient {
478481
let mut user_ids = BTreeSet::new();
479482
let mut profiles = BTreeMap::new();
480483

481-
let room_id = room_info.room_id.clone();
482-
483484
for raw_event in events {
484485
let event = match raw_event.deserialize() {
485-
Ok(e) => e,
486+
Ok(ev) => ev,
486487
Err(e) => {
487-
warn!(?room_id, "Couldn't deserialize state event: {e:?}");
488+
warn!("Couldn't deserialize state event: {e}");
488489
continue;
489490
}
490491
};
491492

492493
room_info.handle_state_event(&event);
493494

494495
if let AnySyncStateEvent::RoomMember(member) = &event {
495-
ambiguity_cache.handle_event(changes, &room_id, member).await?;
496+
ambiguity_cache.handle_event(changes, &room_info.room_id, member).await?;
496497

497498
match member.membership() {
498499
MembershipState::Join | MembershipState::Invite => {
@@ -516,12 +517,13 @@ impl BaseClient {
516517
.insert(event.state_key().to_owned(), raw_event.clone());
517518
}
518519

519-
changes.profiles.insert((*room_id).to_owned(), profiles);
520-
changes.state.insert((*room_id).to_owned(), state_events);
520+
changes.profiles.insert((*room_info.room_id).to_owned(), profiles);
521+
changes.state.insert((*room_info.room_id).to_owned(), state_events);
521522

522523
Ok(user_ids)
523524
}
524525

526+
#[instrument(skip_all, fields(?room_id))]
525527
pub(crate) async fn handle_room_account_data(
526528
&self,
527529
room_id: &RoomId,
@@ -535,6 +537,7 @@ impl BaseClient {
535537
}
536538
}
537539

540+
#[instrument(skip_all)]
538541
pub(crate) async fn handle_account_data(
539542
&self,
540543
events: &[Raw<AnyGlobalAccountDataEvent>],
@@ -580,6 +583,7 @@ impl BaseClient {
580583
}
581584

582585
#[cfg(feature = "e2e-encryption")]
586+
#[instrument(skip_all)]
583587
pub(crate) async fn preprocess_to_device_events(
584588
&self,
585589
to_device_events: Vec<Raw<ruma::events::AnyToDeviceEvent>>,
@@ -656,6 +660,7 @@ impl BaseClient {
656660
/// # Arguments
657661
///
658662
/// * `response` - The response that we received after a successful sync.
663+
#[instrument(skip_all)]
659664
pub async fn receive_sync_response(
660665
&self,
661666
response: api::sync::sync_events::v3::Response,
@@ -720,13 +725,21 @@ impl BaseClient {
720725
)
721726
.await?;
722727

723-
if let Some(event) =
724-
new_info.ephemeral.events.iter().find_map(|e| match e.deserialize() {
725-
Ok(AnySyncEphemeralRoomEvent::Receipt(event)) => Some(event.content),
726-
_ => None,
727-
})
728-
{
729-
changes.add_receipts(&room_id, event);
728+
for raw in &new_info.ephemeral.events {
729+
match raw.deserialize() {
730+
Ok(AnySyncEphemeralRoomEvent::Receipt(event)) => {
731+
changes.add_receipts(&room_id, event.content);
732+
}
733+
Ok(_) => {}
734+
Err(e) => {
735+
let event_id: Option<String> = raw.get_field("event_id").ok().flatten();
736+
#[rustfmt::skip]
737+
info!(
738+
?room_id, event_id,
739+
"Failed to deserialize ephemeral room event: {e}"
740+
);
741+
}
742+
}
730743
}
731744

732745
if new_info.timeline.limited {
@@ -907,6 +920,7 @@ impl BaseClient {
907920
/// * `room_id` - The room id this response belongs to.
908921
///
909922
/// * `response` - The raw response that was received from the server.
923+
#[instrument(skip_all, fields(?room_id))]
910924
pub async fn receive_members(
911925
&self,
912926
room_id: &RoomId,

0 commit comments

Comments
 (0)