Skip to content

Commit ea5478c

Browse files
authored
Merge pull request #510 from matrix-org/jplatte/up-ruma
2 parents dec4772 + 1f2fd38 commit ea5478c

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

54 files changed

+427
-425
lines changed

.github/workflows/ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ jobs:
3030
uses: actions-rs/cargo@v1
3131
with:
3232
command: fmt
33-
args: --all -- --check
33+
args: -- --check
3434

3535
typos:
3636
name: Spell Check with Typos

Cargo.toml

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,2 @@
11
[workspace]
2-
members = [
3-
"crates/matrix-qrcode",
4-
"crates/matrix-sdk",
5-
"crates/matrix-sdk-appservice",
6-
"crates/matrix-sdk-base",
7-
"crates/matrix-sdk-common",
8-
"crates/matrix-sdk-crypto",
9-
"crates/matrix-sdk-test",
10-
"crates/matrix-sdk-test-macros",
11-
]
2+
members = ["crates/*"]

crates/matrix-qrcode/Cargo.toml

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -24,13 +24,7 @@ base64 = "0.13.0"
2424
byteorder = "1.4.3"
2525
image = { version = "0.23.14", optional = true }
2626
qrcode = { version = "0.12.0", default-features = false }
27+
ruma-identifiers = "0.22.0"
28+
ruma-serde = "0.6.0"
2729
rqrr = { version = "0.4.0", optional = true }
2830
thiserror = "1.0.25"
29-
30-
[dependencies.ruma-identifiers]
31-
git = "https://github.com/ruma/ruma/"
32-
rev = "b9f32bc6327542d382d4eb42ec43623495c50e66"
33-
34-
[dependencies.ruma-serde]
35-
git = "https://github.com/ruma/ruma/"
36-
rev = "b9f32bc6327542d382d4eb42ec43623495c50e66"

crates/matrix-sdk-appservice/Cargo.toml

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ dashmap = "4"
2828
http = "0.2"
2929
matrix-sdk = { version = "0.4", path = "../matrix-sdk", default-features = false, features = ["appservice"] }
3030
regex = "1"
31+
ruma = { version = "0.5.0", features = ["client-api-c", "appservice-api-s"] }
3132
serde = "1"
3233
serde_json = "1"
3334
serde_yaml = "0.8"
@@ -36,11 +37,6 @@ tracing = "0.1"
3637
url = "2"
3738
warp = { version = "0.3.1", optional = true, default-features = false }
3839

39-
[dependencies.ruma]
40-
git = "https://github.com/ruma/ruma/"
41-
rev = "b9f32bc6327542d382d4eb42ec43623495c50e66"
42-
features = ["client-api-c", "appservice-api-s"]
43-
4440
[dev-dependencies]
4541
matrix-sdk-test = { version = "0.4", path = "../matrix-sdk-test", features = ["appservice"] }
4642
mockito = "0.30"

crates/matrix-sdk-appservice/src/error.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
// See the License for the specific language governing permissions and
1313
// limitations under the License.
1414

15-
use ruma::api::client::r0::uiaa::UiaaInfo;
15+
use ruma::api::client::uiaa::UiaaInfo;
1616
use thiserror::Error;
1717

1818
#[derive(Error, Debug)]

crates/matrix-sdk-appservice/src/lib.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ use ruma::{
105105
query::{query_room_alias::v1 as query_room, query_user_id::v1 as query_user},
106106
Registration,
107107
},
108-
client::r0::account::register,
108+
client::account::register,
109109
},
110110
assign, identifiers, DeviceId, ServerName, UserId,
111111
};
@@ -448,7 +448,7 @@ impl AppService {
448448
*self.event_handler.rooms.lock().await = Some(handler);
449449
}
450450

451-
/// Register a virtual user by sending a [`register::Request`] to the
451+
/// Register a virtual user by sending a [`register::v3::Request`] to the
452452
/// homeserver
453453
///
454454
/// # Arguments
@@ -463,7 +463,7 @@ impl AppService {
463463
if self.is_user_registered(localpart.as_ref()).await? {
464464
return Ok(());
465465
}
466-
let request = assign!(register::Request::new(), {
466+
let request = assign!(register::v3::Request::new(), {
467467
username: Some(localpart.as_ref()),
468468
login_type: Some(&register::LoginType::ApplicationService),
469469
});

crates/matrix-sdk-base/Cargo.toml

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ matrix-sdk-common = { version = "0.4.0", path = "../matrix-sdk-common" }
4646
matrix-sdk-crypto = { version = "0.4.0", path = "../matrix-sdk-crypto", optional = true }
4747
pbkdf2 = { version = "0.10.0", default-features = false, optional = true }
4848
rand = { version = "0.8.4", optional = true }
49+
ruma = { version = "0.5.0", features = ["client-api-c", "signatures", "unstable-pre-spec"] }
4950
serde = { version = "1.0.126", features = ["rc"] }
5051
serde_json = "1.0.64"
5152
sha2 = { version = "0.10.1", optional = true }
@@ -61,11 +62,6 @@ tokio = { version = "1.7.1", optional = true, default-features = false, features
6162
indexed_db_futures = { version = "0.2.0", optional = true }
6263
wasm-bindgen = { version = "0.2.74", features = ["serde-serialize"], optional = true }
6364

64-
[dependencies.ruma]
65-
git = "https://github.com/ruma/ruma/"
66-
rev = "b9f32bc6327542d382d4eb42ec43623495c50e66"
67-
features = ["client-api-c", "unstable-pre-spec"]
68-
6965
[dev-dependencies]
7066
futures = { version = "0.3.15", default-features = false, features = ["executor"] }
7167
http = "0.2.4"

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

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -44,15 +44,15 @@ use matrix_sdk_crypto::{
4444
};
4545
#[cfg(feature = "encryption")]
4646
use ruma::{
47-
api::client::r0::keys::claim_keys::Request as KeysClaimRequest,
47+
api::client::keys::claim_keys::v3::Request as KeysClaimRequest,
4848
events::{
4949
room::{encrypted::RoomEncryptedEventContent, history_visibility::HistoryVisibility},
5050
AnySyncMessageEvent, MessageEventContent,
5151
},
5252
DeviceId, TransactionId,
5353
};
5454
use ruma::{
55-
api::client::r0::{self as api, push::get_notifications::Notification},
55+
api::client::{self as api, push::get_notifications::v3::Notification},
5656
events::{
5757
room::member::MembershipState, AnyGlobalAccountDataEvent, AnyRoomAccountDataEvent,
5858
AnyStrippedStateEvent, AnySyncEphemeralRoomEvent, AnySyncRoomEvent, AnySyncStateEvent,
@@ -355,7 +355,7 @@ impl BaseClient {
355355
/// and device id.
356356
pub async fn receive_login_response(
357357
&self,
358-
response: &api::session::login::Response,
358+
response: &api::session::login::v3::Response,
359359
) -> Result<()> {
360360
let session = Session {
361361
access_token: response.access_token.clone(),
@@ -430,7 +430,7 @@ impl BaseClient {
430430
async fn handle_timeline(
431431
&self,
432432
room: &Room,
433-
ruma_timeline: api::sync::sync_events::Timeline,
433+
ruma_timeline: api::sync::sync_events::v3::Timeline,
434434
push_rules: &Ruleset,
435435
room_info: &mut RoomInfo,
436436
changes: &mut StateChanges,
@@ -727,10 +727,10 @@ impl BaseClient {
727727
/// * `response` - The response that we received after a successful sync.
728728
pub async fn receive_sync_response(
729729
&self,
730-
response: api::sync::sync_events::Response,
730+
response: api::sync::sync_events::v3::Response,
731731
) -> Result<SyncResponse> {
732732
#[allow(unused_variables)]
733-
let api::sync::sync_events::Response {
733+
let api::sync::sync_events::v3::Response {
734734
next_batch,
735735
rooms,
736736
presence,
@@ -1009,7 +1009,7 @@ impl BaseClient {
10091009
pub async fn receive_members(
10101010
&self,
10111011
room_id: &RoomId,
1012-
response: &api::membership::get_member_events::Response,
1012+
response: &api::membership::get_member_events::v3::Response,
10131013
) -> Result<MembersResponse> {
10141014
let members: Vec<MemberEvent> = response
10151015
.chunk
@@ -1094,7 +1094,7 @@ impl BaseClient {
10941094
pub async fn receive_filter_upload(
10951095
&self,
10961096
filter_name: &str,
1097-
response: &api::filter::create_filter::Response,
1097+
response: &api::filter::create_filter::v3::Response,
10981098
) -> Result<()> {
10991099
Ok(self.store.save_filter(filter_name, &response.filter_id).await?)
11001100
}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
//! Common types for [media content](https://matrix.org/docs/spec/client_server/r0.6.1#id66).
22
33
use ruma::{
4-
api::client::r0::media::get_content_thumbnail::Method,
4+
api::client::media::get_content_thumbnail::v3::Method,
55
events::{
66
room::{
77
message::{

crates/matrix-sdk-base/src/rooms/normal.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ use futures_core::stream::Stream;
2020
use futures_util::stream::{self, StreamExt};
2121
use matrix_sdk_common::locks::Mutex;
2222
use ruma::{
23-
api::client::r0::sync::sync_events::RoomSummary as RumaSummary,
23+
api::client::sync::sync_events::v3::RoomSummary as RumaSummary,
2424
events::{
2525
receipt::Receipt,
2626
room::{

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,8 @@ pub struct Session {
4545
pub device_id: Box<DeviceId>,
4646
}
4747

48-
impl From<ruma::api::client::r0::session::login::Response> for Session {
49-
fn from(response: ruma::api::client::r0::session::login::Response) -> Self {
48+
impl From<ruma::api::client::session::login::v3::Response> for Session {
49+
fn from(response: ruma::api::client::session::login::v3::Response) -> Self {
5050
Self {
5151
access_token: response.access_token,
5252
user_id: response.user_id,

crates/matrix-sdk-base/src/store/indexeddb_store.rs

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,11 @@ use ruma::{
2323
receipt::Receipt,
2424
room::member::{MembershipState, RoomMemberEventContent},
2525
AnyGlobalAccountDataEvent, AnyRoomAccountDataEvent, AnySyncMessageEvent, AnySyncRoomEvent,
26-
AnySyncStateEvent, EventType, Redact,
26+
AnySyncStateEvent, EventType,
2727
},
2828
receipt::ReceiptType,
2929
serde::Raw,
30+
signatures::{redact_in_place, CanonicalJsonObject},
3031
EventId, MxcUri, RoomId, RoomVersionId, UserId,
3132
};
3233
use serde::{Deserialize, Serialize};
@@ -623,10 +624,11 @@ impl IndexeddbStore {
623624
})
624625
.transpose()?
625626
{
626-
let inner_event = full_event.event.deserialize()?;
627-
full_event.event = Raw::new(&AnySyncRoomEvent::from(
628-
inner_event.redact(redaction, &room_version),
629-
))?;
627+
let mut event_json: CanonicalJsonObject =
628+
full_event.event.deserialize_as()?;
629+
redact_in_place(&mut event_json, &room_version)
630+
.map_err(StoreError::Redaction)?;
631+
full_event.event = Raw::new(&event_json)?.cast();
630632
timeline_store.put_key_val_owned(
631633
position_key,
632634
&self.serialize_event(&full_event)?,

crates/matrix-sdk-base/src/store/integration_tests.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,11 @@ macro_rules! statestore_integration_tests {
1010
use matrix_sdk_test::{async_test, test_json};
1111
use ruma::{
1212
api::{
13-
client::r0::{
14-
media::get_content_thumbnail::Method,
15-
message::get_message_events::Response as MessageResponse,
16-
sync::sync_events::Response as SyncResponse,
17-
},
13+
client::{
14+
media::get_content_thumbnail::v3::Method,
15+
message::get_message_events::v3::Response as MessageResponse,
16+
sync::sync_events::v3::Response as SyncResponse,
17+
},
1818
IncomingResponse,
1919
},
2020
device_id, event_id,

crates/matrix-sdk-base/src/store/memory_store.rs

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,11 @@ use ruma::{
2828
receipt::Receipt,
2929
room::member::{MembershipState, RoomMemberEventContent},
3030
AnyGlobalAccountDataEvent, AnyRoomAccountDataEvent, AnyStrippedStateEvent,
31-
AnySyncMessageEvent, AnySyncRoomEvent, AnySyncStateEvent, EventType, Redact,
31+
AnySyncMessageEvent, AnySyncRoomEvent, AnySyncStateEvent, EventType,
3232
},
3333
receipt::ReceiptType,
3434
serde::Raw,
35+
signatures::{redact_in_place, CanonicalJsonObject},
3536
EventId, MxcUri, RoomId, RoomVersionId, UserId,
3637
};
3738
#[allow(unused_imports)]
@@ -41,6 +42,7 @@ use super::{BoxStream, Result, RoomInfo, StateChanges, StateStore};
4142
use crate::{
4243
deserialized_responses::{MemberEvent, StrippedMemberEvent, SyncRoomEvent},
4344
media::{MediaRequest, UniqueKey},
45+
StoreError,
4446
};
4547

4648
#[allow(clippy::type_complexity)]
@@ -352,14 +354,13 @@ impl MemoryStore {
352354

353355
if let Some(position) = pos {
354356
if let Some(mut full_event) = data.events.get_mut(&position.clone()) {
355-
let inner_event = full_event.event.deserialize()?;
356-
if room_version.is_none() {
357-
room_version = Some(make_room_version());
358-
}
357+
let mut event_json: CanonicalJsonObject =
358+
full_event.event.deserialize_as()?;
359+
let v = room_version.get_or_insert_with(make_room_version);
359360

360-
full_event.event = Raw::new(&AnySyncRoomEvent::from(
361-
inner_event.redact(redaction, room_version.as_ref().unwrap()),
362-
))?;
361+
redact_in_place(&mut event_json, v)
362+
.map_err(StoreError::Redaction)?;
363+
full_event.event = Raw::new(&event_json)?.cast();
363364
}
364365
}
365366
}

crates/matrix-sdk-base/src/store/mod.rs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ pub mod integration_tests;
2828
use dashmap::DashMap;
2929
use matrix_sdk_common::{async_trait, locks::RwLock, AsyncTraitDeps};
3030
use ruma::{
31-
api::client::r0::push::get_notifications::Notification,
31+
api::client::push::get_notifications::v3::Notification,
3232
events::{
3333
presence::PresenceEvent,
3434
receipt::{Receipt, ReceiptEventContent},
@@ -113,6 +113,11 @@ pub enum StoreError {
113113
#[cfg(feature = "sled_state_store")]
114114
#[error(transparent)]
115115
Task(#[from] tokio::task::JoinError),
116+
/// Redacting an event in the store has failed.
117+
///
118+
/// This should never happen.
119+
#[error("Redaction failed: {0}")]
120+
Redaction(#[source] ruma::signatures::Error),
116121
}
117122

118123
#[cfg(feature = "indexeddb_state_store")]

crates/matrix-sdk-base/src/store/sled_store.rs

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,11 @@ use ruma::{
3030
receipt::Receipt,
3131
room::member::{MembershipState, RoomMemberEventContent},
3232
AnyGlobalAccountDataEvent, AnyRoomAccountDataEvent, AnySyncMessageEvent, AnySyncRoomEvent,
33-
AnySyncStateEvent, EventType, Redact,
33+
AnySyncStateEvent, EventType,
3434
},
3535
receipt::ReceiptType,
3636
serde::Raw,
37+
signatures::{redact_in_place, CanonicalJsonObject},
3738
EventId, MxcUri, RoomId, RoomVersionId, UserId,
3839
};
3940
use serde::{Deserialize, Serialize};
@@ -1181,11 +1182,11 @@ impl SledStore {
11811182
})
11821183
.transpose()?
11831184
{
1184-
let inner_event = full_event.event.deserialize()?;
1185-
1186-
full_event.event = Raw::new(&AnySyncRoomEvent::from(
1187-
inner_event.redact(redaction, &room_version),
1188-
))?;
1185+
let mut event_json: CanonicalJsonObject =
1186+
full_event.event.deserialize_as()?;
1187+
redact_in_place(&mut event_json, &room_version)
1188+
.map_err(StoreError::Redaction)?;
1189+
full_event.event = Raw::new(&event_json)?.cast();
11891190
timeline_batch
11901191
.insert(position_key, self.serialize_event(&full_event)?);
11911192
}

crates/matrix-sdk-common/Cargo.toml

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,9 @@ targets = ["x86_64-unknown-linux-gnu", "wasm32-unknown-unknown"]
1717

1818
[dependencies]
1919
async-trait = "0.1.50"
20+
ruma = { version = "0.5.0", features = ["client-api-c"] }
2021
serde = "1.0.126"
2122

22-
[dependencies.ruma]
23-
git = "https://github.com/ruma/ruma/"
24-
rev = "b9f32bc6327542d382d4eb42ec43623495c50e66"
25-
features = ["client-api-c"]
26-
2723
[target.'cfg(not(target_arch = "wasm32"))'.dependencies]
2824
uuid = { version = "0.8.2", default-features = false, features = [
2925
"v4",

0 commit comments

Comments
 (0)