Skip to content

Commit 8cc334a

Browse files
committed
chore: Upgrade Ruma to 0.11.0
Signed-off-by: Kévin Commaille <[email protected]>
1 parent 40f4fc1 commit 8cc334a

File tree

20 files changed

+178
-162
lines changed

20 files changed

+178
-162
lines changed

Cargo.lock

Lines changed: 27 additions & 18 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
@@ -45,7 +45,7 @@ once_cell = "1.16.0"
4545
pin-project-lite = "0.2.9"
4646
rand = "0.8.5"
4747
reqwest = { version = "0.12.4", default-features = false }
48-
ruma = { git = "https://github.com/ruma/ruma", rev = "26165b23fc2ae9928c5497a21db3d31f4b44cc2a", features = [
48+
ruma = { version = "0.11.0", features = [
4949
"client-api-c",
5050
"compat-upload-signatures",
5151
"compat-user-id",
@@ -59,7 +59,7 @@ ruma = { git = "https://github.com/ruma/ruma", rev = "26165b23fc2ae9928c5497a21d
5959
"unstable-msc4075",
6060
"unstable-msc4140",
6161
] }
62-
ruma-common = { git = "https://github.com/ruma/ruma", rev = "26165b23fc2ae9928c5497a21db3d31f4b44cc2a" }
62+
ruma-common = "0.14.0"
6363
serde = "1.0.151"
6464
serde_html_form = "0.2.0"
6565
serde_json = "1.0.91"

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

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,8 @@ use ruma::{
4242
},
4343
serde::Raw,
4444
to_device::DeviceIdOrAllDevices,
45-
DeviceKeyAlgorithm, EventId, OwnedTransactionId, OwnedUserId, RoomId, UserId,
45+
DeviceKeyAlgorithm, EventId, OneTimeKeyAlgorithm, OwnedTransactionId, OwnedUserId, RoomId,
46+
UserId,
4647
};
4748
use serde::{Deserialize, Serialize};
4849
use serde_json::{value::RawValue, Value};
@@ -528,20 +529,20 @@ impl OlmMachine {
528529
) -> Result<SyncChangesResult, CryptoStoreError> {
529530
let to_device: ToDevice = serde_json::from_str(&events)?;
530531
let device_changes: RumaDeviceLists = device_changes.into();
531-
let key_counts: BTreeMap<DeviceKeyAlgorithm, UInt> = key_counts
532+
let key_counts: BTreeMap<OneTimeKeyAlgorithm, UInt> = key_counts
532533
.into_iter()
533534
.map(|(k, v)| {
534535
(
535-
DeviceKeyAlgorithm::from(k),
536+
OneTimeKeyAlgorithm::from(k),
536537
v.clamp(0, i32::MAX)
537538
.try_into()
538539
.expect("Couldn't convert key counts into an UInt"),
539540
)
540541
})
541542
.collect();
542543

543-
let unused_fallback_keys: Option<Vec<DeviceKeyAlgorithm>> =
544-
unused_fallback_keys.map(|u| u.into_iter().map(DeviceKeyAlgorithm::from).collect());
544+
let unused_fallback_keys: Option<Vec<OneTimeKeyAlgorithm>> =
545+
unused_fallback_keys.map(|u| u.into_iter().map(OneTimeKeyAlgorithm::from).collect());
545546

546547
let (to_device_events, room_key_infos) = self.runtime.block_on(
547548
self.inner.receive_sync_changes(matrix_sdk_crypto::EncryptionSyncChanges {

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

Lines changed: 36 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ use ruma::{
4343
api::client as api,
4444
events::{
4545
ignored_user_list::IgnoredUserListEvent,
46+
marked_unread::MarkedUnreadEventContent,
4647
push_rules::{PushRulesEvent, PushRulesEventContent},
4748
room::{
4849
member::{MembershipState, RoomMemberEventContent, SyncRoomMemberEvent},
@@ -683,6 +684,25 @@ impl BaseClient {
683684
}
684685
}
685686

687+
// Helper to update the unread marker for stable and unstable prefixes.
688+
fn on_unread_marker(
689+
room_id: &RoomId,
690+
content: &MarkedUnreadEventContent,
691+
room_info: &mut RoomInfo,
692+
room_info_notable_updates: &mut BTreeMap<OwnedRoomId, RoomInfoNotableUpdateReasons>,
693+
) {
694+
if room_info.base_info.is_marked_unread != content.unread {
695+
// Notify the room list about a manual read marker change if the
696+
// value's changed.
697+
room_info_notable_updates
698+
.entry(room_id.to_owned())
699+
.or_default()
700+
.insert(RoomInfoNotableUpdateReasons::UNREAD_MARKER);
701+
}
702+
703+
room_info.base_info.is_marked_unread = content.unread;
704+
}
705+
686706
// Handle new events.
687707
for raw_event in events {
688708
match raw_event.deserialize() {
@@ -692,19 +712,24 @@ impl BaseClient {
692712
match event {
693713
AnyRoomAccountDataEvent::MarkedUnread(event) => {
694714
on_room_info(room_id, changes, self, |room_info| {
695-
if room_info.base_info.is_marked_unread != event.content.unread {
696-
// Notify the room list about a manual read marker change if the
697-
// value's changed.
698-
room_info_notable_updates
699-
.entry(room_id.to_owned())
700-
.or_default()
701-
.insert(RoomInfoNotableUpdateReasons::UNREAD_MARKER);
702-
}
703-
704-
room_info.base_info.is_marked_unread = event.content.unread;
715+
on_unread_marker(
716+
room_id,
717+
&event.content,
718+
room_info,
719+
room_info_notable_updates,
720+
);
721+
});
722+
}
723+
AnyRoomAccountDataEvent::UnstableMarkedUnread(event) => {
724+
on_room_info(room_id, changes, self, |room_info| {
725+
on_unread_marker(
726+
room_id,
727+
&event.content.0,
728+
room_info,
729+
room_info_notable_updates,
730+
);
705731
});
706732
}
707-
708733
AnyRoomAccountDataEvent::Tag(event) => {
709734
on_room_info(room_id, changes, self, |room_info| {
710735
room_info.base_info.handle_notable_tags(&event.content.tags);

crates/matrix-sdk-crypto/src/backups/mod.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -224,19 +224,19 @@ impl BackupMachine {
224224
if device_key_id.algorithm() == DeviceKeyAlgorithm::Ed25519 {
225225
// No need to check our own device here, we're doing that using
226226
// the check_own_device_signature().
227-
if device_key_id.device_id() == self.store.static_account().device_id {
227+
if device_key_id.key_name() == self.store.static_account().device_id {
228228
continue;
229229
}
230230

231231
let state = self
232232
.test_ed25519_device_signature(
233-
device_key_id.device_id(),
233+
device_key_id.key_name(),
234234
signatures,
235235
auth_data,
236236
)
237237
.await?;
238238

239-
result.insert(device_key_id.device_id().to_owned(), state);
239+
result.insert(device_key_id.key_name().to_owned(), state);
240240

241241
// Abort the loop if we found a trusted and valid signature,
242242
// unless we should check all of them.

crates/matrix-sdk-crypto/src/gossiping/machine.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ use ruma::{
3434
events::secret::request::{
3535
RequestAction, SecretName, ToDeviceSecretRequestEvent as SecretRequestEvent,
3636
},
37-
DeviceId, DeviceKeyAlgorithm, OwnedDeviceId, OwnedTransactionId, OwnedUserId, RoomId,
37+
DeviceId, OneTimeKeyAlgorithm, OwnedDeviceId, OwnedTransactionId, OwnedUserId, RoomId,
3838
TransactionId, UserId,
3939
};
4040
use tracing::{debug, field::debug, info, instrument, trace, warn, Span};
@@ -178,7 +178,7 @@ impl GossipMachine {
178178
.map(|(key, value)| {
179179
let device_map = value
180180
.iter()
181-
.map(|d| (d.to_owned(), DeviceKeyAlgorithm::SignedCurve25519))
181+
.map(|d| (d.to_owned(), OneTimeKeyAlgorithm::SignedCurve25519))
182182
.collect();
183183

184184
(key.to_owned(), device_map)

crates/matrix-sdk-crypto/src/machine/mod.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ use ruma::{
4444
AnyToDeviceEvent, MessageLikeEventContent,
4545
},
4646
serde::{JsonObject, Raw},
47-
DeviceId, DeviceKeyAlgorithm, MilliSecondsSinceUnixEpoch, OwnedDeviceId, OwnedDeviceKeyId,
47+
DeviceId, MilliSecondsSinceUnixEpoch, OneTimeKeyAlgorithm, OwnedDeviceId, OwnedDeviceKeyId,
4848
OwnedTransactionId, OwnedUserId, RoomId, TransactionId, UInt, UserId,
4949
};
5050
use serde_json::{value::to_raw_value, Value};
@@ -2557,9 +2557,9 @@ pub struct EncryptionSyncChanges<'a> {
25572557
/// sync response.
25582558
pub changed_devices: &'a DeviceLists,
25592559
/// The number of one time keys, as returned in the sync response.
2560-
pub one_time_keys_counts: &'a BTreeMap<DeviceKeyAlgorithm, UInt>,
2560+
pub one_time_keys_counts: &'a BTreeMap<OneTimeKeyAlgorithm, UInt>,
25612561
/// An optional list of fallback keys.
2562-
pub unused_fallback_keys: Option<&'a [DeviceKeyAlgorithm]>,
2562+
pub unused_fallback_keys: Option<&'a [OneTimeKeyAlgorithm]>,
25632563
/// A next-batch token obtained from a to-device sync query.
25642564
pub next_batch_token: Option<String>,
25652565
}

crates/matrix-sdk-crypto/src/machine/test_helpers.rs

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,15 @@ use as_variant::as_variant;
2121
use matrix_sdk_test::{ruma_response_from_json, test_json};
2222
use ruma::{
2323
api::client::keys::{
24-
claim_keys, get_keys, get_keys::v3::Response as KeysQueryResponse, upload_keys,
24+
claim_keys,
25+
get_keys::{self, v3::Response as KeysQueryResponse},
26+
upload_keys,
2527
},
2628
device_id,
2729
encryption::OneTimeKey,
2830
events::dummy::ToDeviceDummyEventContent,
2931
serde::Raw,
30-
user_id, DeviceId, OwnedDeviceKeyId, TransactionId, UserId,
32+
user_id, DeviceId, OwnedOneTimeKeyId, TransactionId, UserId,
3133
};
3234
use serde_json::json;
3335

@@ -37,7 +39,7 @@ use crate::{
3739
};
3840

3941
/// These keys need to be periodically uploaded to the server.
40-
type OneTimeKeys = BTreeMap<OwnedDeviceKeyId, Raw<OneTimeKey>>;
42+
type OneTimeKeys = BTreeMap<OwnedOneTimeKeyId, Raw<OneTimeKey>>;
4143

4244
fn alice_device_id() -> &'static DeviceId {
4345
device_id!("JLAFKJWSCS")
@@ -178,7 +180,7 @@ pub async fn create_session(
178180
machine: &OlmMachine,
179181
user_id: &UserId,
180182
device_id: &DeviceId,
181-
key_id: OwnedDeviceKeyId,
183+
key_id: OwnedOneTimeKeyId,
182184
one_time_key: Raw<OneTimeKey>,
183185
) {
184186
let one_time_keys = BTreeMap::from([(

crates/matrix-sdk-crypto/src/machine/tests/mod.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ use ruma::{
3737
room_id,
3838
serde::Raw,
3939
uint, user_id, DeviceId, DeviceKeyAlgorithm, DeviceKeyId, MilliSecondsSinceUnixEpoch,
40-
TransactionId, UserId,
40+
OneTimeKeyAlgorithm, TransactionId, UserId,
4141
};
4242
use serde_json::json;
4343
use vodozemac::{
@@ -174,7 +174,7 @@ async fn test_generate_one_time_keys() {
174174
.await
175175
.unwrap();
176176

177-
response.one_time_key_counts.insert(DeviceKeyAlgorithm::SignedCurve25519, uint!(50));
177+
response.one_time_key_counts.insert(OneTimeKeyAlgorithm::SignedCurve25519, uint!(50));
178178

179179
machine.receive_keys_upload_response(&response).await.unwrap();
180180

@@ -275,7 +275,7 @@ fn test_one_time_key_signing() {
275275
async fn test_keys_for_upload() {
276276
let machine = OlmMachine::new(user_id(), alice_device_id()).await;
277277

278-
let key_counts = BTreeMap::from([(DeviceKeyAlgorithm::SignedCurve25519, 49u8.into())]);
278+
let key_counts = BTreeMap::from([(OneTimeKeyAlgorithm::SignedCurve25519, 49u8.into())]);
279279
machine
280280
.receive_sync_changes(EncryptionSyncChanges {
281281
to_device_events: Vec::new(),
@@ -327,7 +327,7 @@ async fn test_keys_for_upload() {
327327

328328
let mut response = keys_upload_response();
329329
response.one_time_key_counts.insert(
330-
DeviceKeyAlgorithm::SignedCurve25519,
330+
OneTimeKeyAlgorithm::SignedCurve25519,
331331
account.max_one_time_keys().try_into().unwrap(),
332332
);
333333

0 commit comments

Comments
 (0)