mirror of
https://github.com/matrix-org/matrix-rust-sdk.git
synced 2026-05-05 14:35:20 -04:00
Upgrade Ruma to 0.5.0
This commit is contained in:
@@ -24,13 +24,7 @@ base64 = "0.13.0"
|
||||
byteorder = "1.4.3"
|
||||
image = { version = "0.23.14", optional = true }
|
||||
qrcode = { version = "0.12.0", default-features = false }
|
||||
ruma-identifiers = "0.22.0"
|
||||
ruma-serde = "0.6.0"
|
||||
rqrr = { version = "0.4.0", optional = true }
|
||||
thiserror = "1.0.25"
|
||||
|
||||
[dependencies.ruma-identifiers]
|
||||
git = "https://github.com/ruma/ruma/"
|
||||
rev = "b9f32bc6327542d382d4eb42ec43623495c50e66"
|
||||
|
||||
[dependencies.ruma-serde]
|
||||
git = "https://github.com/ruma/ruma/"
|
||||
rev = "b9f32bc6327542d382d4eb42ec43623495c50e66"
|
||||
|
||||
@@ -28,6 +28,7 @@ dashmap = "4"
|
||||
http = "0.2"
|
||||
matrix-sdk = { version = "0.4", path = "../matrix-sdk", default-features = false, features = ["appservice"] }
|
||||
regex = "1"
|
||||
ruma = { version = "0.5.0", features = ["client-api-c", "appservice-api-s"] }
|
||||
serde = "1"
|
||||
serde_json = "1"
|
||||
serde_yaml = "0.8"
|
||||
@@ -36,11 +37,6 @@ tracing = "0.1"
|
||||
url = "2"
|
||||
warp = { version = "0.3.1", optional = true, default-features = false }
|
||||
|
||||
[dependencies.ruma]
|
||||
git = "https://github.com/ruma/ruma/"
|
||||
rev = "b9f32bc6327542d382d4eb42ec43623495c50e66"
|
||||
features = ["client-api-c", "appservice-api-s"]
|
||||
|
||||
[dev-dependencies]
|
||||
matrix-sdk-test = { version = "0.4", path = "../matrix-sdk-test", features = ["appservice"] }
|
||||
mockito = "0.30"
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
use ruma::api::client::r0::uiaa::UiaaInfo;
|
||||
use ruma::api::client::uiaa::UiaaInfo;
|
||||
use thiserror::Error;
|
||||
|
||||
#[derive(Error, Debug)]
|
||||
|
||||
@@ -105,7 +105,7 @@ use ruma::{
|
||||
query::{query_room_alias::v1 as query_room, query_user_id::v1 as query_user},
|
||||
Registration,
|
||||
},
|
||||
client::r0::account::register,
|
||||
client::account::register,
|
||||
},
|
||||
assign, identifiers, DeviceId, ServerName, UserId,
|
||||
};
|
||||
@@ -448,7 +448,7 @@ impl AppService {
|
||||
*self.event_handler.rooms.lock().await = Some(handler);
|
||||
}
|
||||
|
||||
/// Register a virtual user by sending a [`register::Request`] to the
|
||||
/// Register a virtual user by sending a [`register::v3::Request`] to the
|
||||
/// homeserver
|
||||
///
|
||||
/// # Arguments
|
||||
@@ -463,7 +463,7 @@ impl AppService {
|
||||
if self.is_user_registered(localpart.as_ref()).await? {
|
||||
return Ok(());
|
||||
}
|
||||
let request = assign!(register::Request::new(), {
|
||||
let request = assign!(register::v3::Request::new(), {
|
||||
username: Some(localpart.as_ref()),
|
||||
login_type: Some(®ister::LoginType::ApplicationService),
|
||||
});
|
||||
|
||||
@@ -46,6 +46,7 @@ matrix-sdk-common = { version = "0.4.0", path = "../matrix-sdk-common" }
|
||||
matrix-sdk-crypto = { version = "0.4.0", path = "../matrix-sdk-crypto", optional = true }
|
||||
pbkdf2 = { version = "0.10.0", default-features = false, optional = true }
|
||||
rand = { version = "0.8.4", optional = true }
|
||||
ruma = { version = "0.5.0", features = ["client-api-c", "signatures", "unstable-pre-spec"] }
|
||||
serde = { version = "1.0.126", features = ["rc"] }
|
||||
serde_json = "1.0.64"
|
||||
sha2 = { version = "0.10.1", optional = true }
|
||||
@@ -61,11 +62,6 @@ tokio = { version = "1.7.1", optional = true, default-features = false, features
|
||||
indexed_db_futures = { version = "0.2.0", optional = true }
|
||||
wasm-bindgen = { version = "0.2.74", features = ["serde-serialize"], optional = true }
|
||||
|
||||
[dependencies.ruma]
|
||||
git = "https://github.com/ruma/ruma/"
|
||||
rev = "b9f32bc6327542d382d4eb42ec43623495c50e66"
|
||||
features = ["client-api-c", "unstable-pre-spec"]
|
||||
|
||||
[dev-dependencies]
|
||||
futures = { version = "0.3.15", default-features = false, features = ["executor"] }
|
||||
http = "0.2.4"
|
||||
|
||||
@@ -44,7 +44,7 @@ use matrix_sdk_crypto::{
|
||||
};
|
||||
#[cfg(feature = "encryption")]
|
||||
use ruma::{
|
||||
api::client::r0::keys::claim_keys::Request as KeysClaimRequest,
|
||||
api::client::keys::claim_keys::v3::Request as KeysClaimRequest,
|
||||
events::{
|
||||
room::{encrypted::RoomEncryptedEventContent, history_visibility::HistoryVisibility},
|
||||
AnySyncMessageEvent, MessageEventContent,
|
||||
@@ -52,7 +52,7 @@ use ruma::{
|
||||
DeviceId, TransactionId,
|
||||
};
|
||||
use ruma::{
|
||||
api::client::r0::{self as api, push::get_notifications::Notification},
|
||||
api::client::{self as api, push::get_notifications::v3::Notification},
|
||||
events::{
|
||||
room::member::MembershipState, AnyGlobalAccountDataEvent, AnyRoomAccountDataEvent,
|
||||
AnyStrippedStateEvent, AnySyncEphemeralRoomEvent, AnySyncRoomEvent, AnySyncStateEvent,
|
||||
@@ -355,7 +355,7 @@ impl BaseClient {
|
||||
/// and device id.
|
||||
pub async fn receive_login_response(
|
||||
&self,
|
||||
response: &api::session::login::Response,
|
||||
response: &api::session::login::v3::Response,
|
||||
) -> Result<()> {
|
||||
let session = Session {
|
||||
access_token: response.access_token.clone(),
|
||||
@@ -430,7 +430,7 @@ impl BaseClient {
|
||||
async fn handle_timeline(
|
||||
&self,
|
||||
room: &Room,
|
||||
ruma_timeline: api::sync::sync_events::Timeline,
|
||||
ruma_timeline: api::sync::sync_events::v3::Timeline,
|
||||
push_rules: &Ruleset,
|
||||
room_info: &mut RoomInfo,
|
||||
changes: &mut StateChanges,
|
||||
@@ -727,10 +727,10 @@ impl BaseClient {
|
||||
/// * `response` - The response that we received after a successful sync.
|
||||
pub async fn receive_sync_response(
|
||||
&self,
|
||||
response: api::sync::sync_events::Response,
|
||||
response: api::sync::sync_events::v3::Response,
|
||||
) -> Result<SyncResponse> {
|
||||
#[allow(unused_variables)]
|
||||
let api::sync::sync_events::Response {
|
||||
let api::sync::sync_events::v3::Response {
|
||||
next_batch,
|
||||
rooms,
|
||||
presence,
|
||||
@@ -1009,7 +1009,7 @@ impl BaseClient {
|
||||
pub async fn receive_members(
|
||||
&self,
|
||||
room_id: &RoomId,
|
||||
response: &api::membership::get_member_events::Response,
|
||||
response: &api::membership::get_member_events::v3::Response,
|
||||
) -> Result<MembersResponse> {
|
||||
let members: Vec<MemberEvent> = response
|
||||
.chunk
|
||||
@@ -1094,7 +1094,7 @@ impl BaseClient {
|
||||
pub async fn receive_filter_upload(
|
||||
&self,
|
||||
filter_name: &str,
|
||||
response: &api::filter::create_filter::Response,
|
||||
response: &api::filter::create_filter::v3::Response,
|
||||
) -> Result<()> {
|
||||
Ok(self.store.save_filter(filter_name, &response.filter_id).await?)
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
//! Common types for [media content](https://matrix.org/docs/spec/client_server/r0.6.1#id66).
|
||||
|
||||
use ruma::{
|
||||
api::client::r0::media::get_content_thumbnail::Method,
|
||||
api::client::media::get_content_thumbnail::v3::Method,
|
||||
events::{
|
||||
room::{
|
||||
message::{
|
||||
|
||||
@@ -20,7 +20,7 @@ use futures_core::stream::Stream;
|
||||
use futures_util::stream::{self, StreamExt};
|
||||
use matrix_sdk_common::locks::Mutex;
|
||||
use ruma::{
|
||||
api::client::r0::sync::sync_events::RoomSummary as RumaSummary,
|
||||
api::client::sync::sync_events::v3::RoomSummary as RumaSummary,
|
||||
events::{
|
||||
receipt::Receipt,
|
||||
room::{
|
||||
|
||||
@@ -45,8 +45,8 @@ pub struct Session {
|
||||
pub device_id: Box<DeviceId>,
|
||||
}
|
||||
|
||||
impl From<ruma::api::client::r0::session::login::Response> for Session {
|
||||
fn from(response: ruma::api::client::r0::session::login::Response) -> Self {
|
||||
impl From<ruma::api::client::session::login::v3::Response> for Session {
|
||||
fn from(response: ruma::api::client::session::login::v3::Response) -> Self {
|
||||
Self {
|
||||
access_token: response.access_token,
|
||||
user_id: response.user_id,
|
||||
|
||||
@@ -23,10 +23,11 @@ use ruma::{
|
||||
receipt::Receipt,
|
||||
room::member::{MembershipState, RoomMemberEventContent},
|
||||
AnyGlobalAccountDataEvent, AnyRoomAccountDataEvent, AnySyncMessageEvent, AnySyncRoomEvent,
|
||||
AnySyncStateEvent, EventType, Redact,
|
||||
AnySyncStateEvent, EventType,
|
||||
},
|
||||
receipt::ReceiptType,
|
||||
serde::Raw,
|
||||
signatures::{redact_in_place, CanonicalJsonObject},
|
||||
EventId, MxcUri, RoomId, RoomVersionId, UserId,
|
||||
};
|
||||
use serde::{Deserialize, Serialize};
|
||||
@@ -623,10 +624,11 @@ impl IndexeddbStore {
|
||||
})
|
||||
.transpose()?
|
||||
{
|
||||
let inner_event = full_event.event.deserialize()?;
|
||||
full_event.event = Raw::new(&AnySyncRoomEvent::from(
|
||||
inner_event.redact(redaction, &room_version),
|
||||
))?;
|
||||
let mut event_json: CanonicalJsonObject =
|
||||
full_event.event.deserialize_as()?;
|
||||
redact_in_place(&mut event_json, &room_version)
|
||||
.map_err(StoreError::Redaction)?;
|
||||
full_event.event = Raw::new(&event_json)?.cast();
|
||||
timeline_store.put_key_val_owned(
|
||||
position_key,
|
||||
&self.serialize_event(&full_event)?,
|
||||
|
||||
@@ -10,11 +10,11 @@ macro_rules! statestore_integration_tests {
|
||||
use matrix_sdk_test::{async_test, test_json};
|
||||
use ruma::{
|
||||
api::{
|
||||
client::r0::{
|
||||
media::get_content_thumbnail::Method,
|
||||
message::get_message_events::Response as MessageResponse,
|
||||
sync::sync_events::Response as SyncResponse,
|
||||
},
|
||||
client::{
|
||||
media::get_content_thumbnail::v3::Method,
|
||||
message::get_message_events::v3::Response as MessageResponse,
|
||||
sync::sync_events::v3::Response as SyncResponse,
|
||||
},
|
||||
IncomingResponse,
|
||||
},
|
||||
device_id, event_id,
|
||||
|
||||
@@ -28,10 +28,11 @@ use ruma::{
|
||||
receipt::Receipt,
|
||||
room::member::{MembershipState, RoomMemberEventContent},
|
||||
AnyGlobalAccountDataEvent, AnyRoomAccountDataEvent, AnyStrippedStateEvent,
|
||||
AnySyncMessageEvent, AnySyncRoomEvent, AnySyncStateEvent, EventType, Redact,
|
||||
AnySyncMessageEvent, AnySyncRoomEvent, AnySyncStateEvent, EventType,
|
||||
},
|
||||
receipt::ReceiptType,
|
||||
serde::Raw,
|
||||
signatures::{redact_in_place, CanonicalJsonObject},
|
||||
EventId, MxcUri, RoomId, RoomVersionId, UserId,
|
||||
};
|
||||
#[allow(unused_imports)]
|
||||
@@ -41,6 +42,7 @@ use super::{BoxStream, Result, RoomInfo, StateChanges, StateStore};
|
||||
use crate::{
|
||||
deserialized_responses::{MemberEvent, StrippedMemberEvent, SyncRoomEvent},
|
||||
media::{MediaRequest, UniqueKey},
|
||||
StoreError,
|
||||
};
|
||||
|
||||
#[allow(clippy::type_complexity)]
|
||||
@@ -352,12 +354,13 @@ impl MemoryStore {
|
||||
|
||||
if let Some(position) = pos {
|
||||
if let Some(mut full_event) = data.events.get_mut(&position.clone()) {
|
||||
let inner_event = full_event.event.deserialize()?;
|
||||
let mut event_json: CanonicalJsonObject =
|
||||
full_event.event.deserialize_as()?;
|
||||
let v = room_version.get_or_insert_with(make_room_version);
|
||||
|
||||
full_event.event = Raw::new(&AnySyncRoomEvent::from(
|
||||
inner_event.redact(redaction, v),
|
||||
))?;
|
||||
redact_in_place(&mut event_json, v)
|
||||
.map_err(StoreError::Redaction)?;
|
||||
full_event.event = Raw::new(&event_json)?.cast();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -28,7 +28,7 @@ pub mod integration_tests;
|
||||
use dashmap::DashMap;
|
||||
use matrix_sdk_common::{async_trait, locks::RwLock, AsyncTraitDeps};
|
||||
use ruma::{
|
||||
api::client::r0::push::get_notifications::Notification,
|
||||
api::client::push::get_notifications::v3::Notification,
|
||||
events::{
|
||||
presence::PresenceEvent,
|
||||
receipt::{Receipt, ReceiptEventContent},
|
||||
@@ -113,6 +113,11 @@ pub enum StoreError {
|
||||
#[cfg(feature = "sled_state_store")]
|
||||
#[error(transparent)]
|
||||
Task(#[from] tokio::task::JoinError),
|
||||
/// Redacting an event in the store has failed.
|
||||
///
|
||||
/// This should never happen.
|
||||
#[error("Redaction failed: {0}")]
|
||||
Redaction(#[source] ruma::signatures::Error),
|
||||
}
|
||||
|
||||
#[cfg(feature = "indexeddb_state_store")]
|
||||
|
||||
@@ -30,10 +30,11 @@ use ruma::{
|
||||
receipt::Receipt,
|
||||
room::member::{MembershipState, RoomMemberEventContent},
|
||||
AnyGlobalAccountDataEvent, AnyRoomAccountDataEvent, AnySyncMessageEvent, AnySyncRoomEvent,
|
||||
AnySyncStateEvent, EventType, Redact,
|
||||
AnySyncStateEvent, EventType,
|
||||
},
|
||||
receipt::ReceiptType,
|
||||
serde::Raw,
|
||||
signatures::{redact_in_place, CanonicalJsonObject},
|
||||
EventId, MxcUri, RoomId, RoomVersionId, UserId,
|
||||
};
|
||||
use serde::{Deserialize, Serialize};
|
||||
@@ -1181,11 +1182,11 @@ impl SledStore {
|
||||
})
|
||||
.transpose()?
|
||||
{
|
||||
let inner_event = full_event.event.deserialize()?;
|
||||
|
||||
full_event.event = Raw::new(&AnySyncRoomEvent::from(
|
||||
inner_event.redact(redaction, &room_version),
|
||||
))?;
|
||||
let mut event_json: CanonicalJsonObject =
|
||||
full_event.event.deserialize_as()?;
|
||||
redact_in_place(&mut event_json, &room_version)
|
||||
.map_err(StoreError::Redaction)?;
|
||||
full_event.event = Raw::new(&event_json)?.cast();
|
||||
timeline_batch
|
||||
.insert(position_key, self.serialize_event(&full_event)?);
|
||||
}
|
||||
|
||||
@@ -17,13 +17,9 @@ targets = ["x86_64-unknown-linux-gnu", "wasm32-unknown-unknown"]
|
||||
|
||||
[dependencies]
|
||||
async-trait = "0.1.50"
|
||||
ruma = { version = "0.5.0", features = ["client-api-c"] }
|
||||
serde = "1.0.126"
|
||||
|
||||
[dependencies.ruma]
|
||||
git = "https://github.com/ruma/ruma/"
|
||||
rev = "b9f32bc6327542d382d4eb42ec43623495c50e66"
|
||||
features = ["client-api-c"]
|
||||
|
||||
[target.'cfg(not(target_arch = "wasm32"))'.dependencies]
|
||||
uuid = { version = "0.8.2", default-features = false, features = [
|
||||
"v4",
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
use std::{collections::BTreeMap, convert::TryFrom};
|
||||
|
||||
use ruma::{
|
||||
api::client::r0::{
|
||||
push::get_notifications::Notification,
|
||||
sync::sync_events::{
|
||||
api::client::{
|
||||
push::get_notifications::v3::Notification,
|
||||
sync::sync_events::v3::{
|
||||
DeviceLists, Ephemeral, GlobalAccountData, InvitedRoom, Presence, RoomAccountData,
|
||||
State, ToDevice, UnreadNotificationsCount as RumaUnreadNotificationsCount,
|
||||
},
|
||||
@@ -411,23 +411,23 @@ mod test {
|
||||
fn room_event_to_sync_room_event() {
|
||||
let content = RoomMessageEventContent::text_plain("foobar");
|
||||
|
||||
let event: AnyMessageEvent = MessageEvent {
|
||||
let event = MessageEvent {
|
||||
content,
|
||||
event_id: event_id!("$xxxxx:example.org").to_owned(),
|
||||
room_id: room_id!("!someroom:example.com").to_owned(),
|
||||
origin_server_ts: MilliSecondsSinceUnixEpoch::now(),
|
||||
sender: user_id!("@carl:example.com").to_owned(),
|
||||
unsigned: Unsigned::default(),
|
||||
}
|
||||
.into();
|
||||
};
|
||||
|
||||
let room_event =
|
||||
RoomEvent { event: Raw::new(&event.clone().into()).unwrap(), encryption_info: None };
|
||||
RoomEvent { event: Raw::new(&event).unwrap().cast(), encryption_info: None };
|
||||
|
||||
let converted_room_event: SyncRoomEvent = room_event.into();
|
||||
|
||||
let converted_event: AnySyncRoomEvent = converted_room_event.event.deserialize().unwrap();
|
||||
|
||||
let event: AnyMessageEvent = event.into();
|
||||
let sync_event: AnySyncMessageEvent = event.into();
|
||||
let sync_event: AnySyncRoomEvent = sync_event.into();
|
||||
|
||||
|
||||
@@ -50,9 +50,9 @@ zeroize = { version = "1.3.0", features = ["zeroize_derive"] }
|
||||
## Feature indexeddb-state-store
|
||||
indexed_db_futures = { version = "0.2.0", optional = true }
|
||||
wasm-bindgen = { version = "0.2.74", features = ["serde-serialize"], optional = true }
|
||||
|
||||
[dependencies.ruma]
|
||||
git = "https://github.com/ruma/ruma/"
|
||||
rev = "b9f32bc6327542d382d4eb42ec43623495c50e66"
|
||||
version = "0.5.0"
|
||||
features = ["client-api-c", "rand", "unstable-msc2676", "unstable-msc2677"]
|
||||
|
||||
[dev-dependencies]
|
||||
|
||||
@@ -21,7 +21,7 @@ use std::{collections::BTreeMap, convert::TryFrom};
|
||||
|
||||
use matrix_sdk_crypto::{OlmMachine, OlmError};
|
||||
use ruma::{
|
||||
api::client::r0::sync::sync_events::{ToDevice, DeviceLists},
|
||||
api::client::sync::sync_events::v3::{ToDevice, DeviceLists},
|
||||
device_id, user_id,
|
||||
};
|
||||
|
||||
|
||||
@@ -5,9 +5,9 @@ use matrix_sdk_crypto::{EncryptionSettings, OlmMachine};
|
||||
use matrix_sdk_test::response_from_file;
|
||||
use ruma::{
|
||||
api::{
|
||||
client::r0::{
|
||||
client::{
|
||||
keys::{claim_keys, get_keys},
|
||||
to_device::send_event_to_device::Response as ToDeviceResponse,
|
||||
to_device::send_event_to_device::v3::Response as ToDeviceResponse,
|
||||
},
|
||||
IncomingResponse,
|
||||
},
|
||||
@@ -24,26 +24,28 @@ fn alice_device_id() -> &'static DeviceId {
|
||||
device_id!("JLAFKJWSCS")
|
||||
}
|
||||
|
||||
fn keys_query_response() -> get_keys::Response {
|
||||
fn keys_query_response() -> get_keys::v3::Response {
|
||||
let data = include_bytes!("./keys_query.json");
|
||||
let data: Value = serde_json::from_slice(data).unwrap();
|
||||
let data = response_from_file(&data);
|
||||
get_keys::Response::try_from_http_response(data).expect("Can't parse the keys upload response")
|
||||
}
|
||||
|
||||
fn keys_claim_response() -> claim_keys::Response {
|
||||
let data = include_bytes!("./keys_claim.json");
|
||||
let data: Value = serde_json::from_slice(data).unwrap();
|
||||
let data = response_from_file(&data);
|
||||
claim_keys::Response::try_from_http_response(data)
|
||||
get_keys::v3::Response::try_from_http_response(data)
|
||||
.expect("Can't parse the keys upload response")
|
||||
}
|
||||
|
||||
fn huge_keys_query_response() -> get_keys::Response {
|
||||
fn keys_claim_response() -> claim_keys::v3::Response {
|
||||
let data = include_bytes!("./keys_claim.json");
|
||||
let data: Value = serde_json::from_slice(data).unwrap();
|
||||
let data = response_from_file(&data);
|
||||
claim_keys::v3::Response::try_from_http_response(data)
|
||||
.expect("Can't parse the keys upload response")
|
||||
}
|
||||
|
||||
fn huge_keys_query_response() -> get_keys::v3::Response {
|
||||
let data = include_bytes!("./keys_query_2000_members.json");
|
||||
let data: Value = serde_json::from_slice(data).unwrap();
|
||||
let data = response_from_file(&data);
|
||||
get_keys::Response::try_from_http_response(data).expect("Can't parse the keys query response")
|
||||
get_keys::v3::Response::try_from_http_response(data)
|
||||
.expect("Can't parse the keys query response")
|
||||
}
|
||||
|
||||
pub fn keys_query(c: &mut Criterion) {
|
||||
|
||||
@@ -19,7 +19,7 @@ use std::{
|
||||
|
||||
use olm_rs::pk::OlmPkEncryption;
|
||||
use ruma::{
|
||||
api::client::r0::backup::{KeyBackupData, KeyBackupDataInit, SessionDataInit},
|
||||
api::client::backup::{KeyBackupData, KeyBackupDataInit, SessionDataInit},
|
||||
DeviceKeyId, UserId,
|
||||
};
|
||||
use zeroize::Zeroizing;
|
||||
|
||||
@@ -30,7 +30,7 @@ use std::{
|
||||
|
||||
use matrix_sdk_common::locks::RwLock;
|
||||
use ruma::{
|
||||
api::client::r0::backup::RoomKeyBackup, serde::Raw, DeviceKeyAlgorithm, DeviceKeyId, RoomId,
|
||||
api::client::backup::RoomKeyBackup, serde::Raw, DeviceKeyAlgorithm, DeviceKeyId, RoomId,
|
||||
TransactionId, UserId,
|
||||
};
|
||||
use serde::{Deserialize, Serialize};
|
||||
@@ -115,7 +115,7 @@ impl BackupMachine {
|
||||
/// and the given Ruma struct will lose the unspecced fields after a
|
||||
/// serialization cycle.
|
||||
///
|
||||
/// [`BackupAlgorithm`]: ruma::api::client::r0::backup::BackupAlgorithm
|
||||
/// [`BackupAlgorithm`]: ruma::api::client::backup::BackupAlgorithm
|
||||
/// [`/room_keys/version`]: https://spec.matrix.org/unstable/client-server-api/#get_matrixclientv3room_keysversion
|
||||
pub async fn verify_backup(
|
||||
&self,
|
||||
|
||||
@@ -24,7 +24,7 @@ use std::{collections::BTreeMap, sync::Arc};
|
||||
|
||||
use dashmap::{mapref::entry::Entry, DashMap, DashSet};
|
||||
use ruma::{
|
||||
api::client::r0::keys::claim_keys::Request as KeysClaimRequest,
|
||||
api::client::keys::claim_keys::v3::Request as KeysClaimRequest,
|
||||
events::{
|
||||
forwarded_room_key::{ToDeviceForwardedRoomKeyEvent, ToDeviceForwardedRoomKeyEventContent},
|
||||
room_key_request::{Action, RequestedKeyInfo, ToDeviceRoomKeyRequestEvent},
|
||||
|
||||
@@ -25,7 +25,7 @@ use std::{
|
||||
use atomic::Atomic;
|
||||
use matrix_sdk_common::locks::Mutex;
|
||||
use ruma::{
|
||||
api::client::r0::keys::upload_signatures::Request as SignatureUploadRequest,
|
||||
api::client::keys::upload_signatures::v3::Request as SignatureUploadRequest,
|
||||
encryption::{DeviceKeys, SignedKey},
|
||||
events::{
|
||||
forwarded_room_key::ToDeviceForwardedRoomKeyEventContent,
|
||||
|
||||
@@ -22,7 +22,7 @@ use std::{
|
||||
use futures_util::future::join_all;
|
||||
use matrix_sdk_common::executor::spawn;
|
||||
use ruma::{
|
||||
api::client::r0::keys::get_keys::Response as KeysQueryResponse, encryption::DeviceKeys,
|
||||
api::client::keys::get_keys::v3::Response as KeysQueryResponse, encryption::DeviceKeys,
|
||||
serde::Raw, DeviceId, UserId,
|
||||
};
|
||||
use tracing::{debug, info, trace, warn};
|
||||
@@ -544,7 +544,7 @@ pub(crate) mod test {
|
||||
use matrix_sdk_common::locks::Mutex;
|
||||
use matrix_sdk_test::async_test;
|
||||
use ruma::{
|
||||
api::{client::r0::keys::get_keys::Response as KeyQueryResponse, IncomingResponse},
|
||||
api::{client::keys::get_keys::v3::Response as KeyQueryResponse, IncomingResponse},
|
||||
device_id, user_id, DeviceId, UserId,
|
||||
};
|
||||
use serde_json::json;
|
||||
|
||||
@@ -23,7 +23,7 @@ use std::{
|
||||
};
|
||||
|
||||
use ruma::{
|
||||
api::client::r0::keys::upload_signatures::Request as SignatureUploadRequest,
|
||||
api::client::keys::upload_signatures::v3::Request as SignatureUploadRequest,
|
||||
encryption::{CrossSigningKey, DeviceKeys, KeyUsage},
|
||||
events::{
|
||||
key::verification::VerificationMethod, room::message::KeyVerificationRequestEventContent,
|
||||
@@ -941,7 +941,7 @@ pub(crate) mod test {
|
||||
|
||||
use matrix_sdk_common::locks::Mutex;
|
||||
use matrix_sdk_test::async_test;
|
||||
use ruma::{api::client::r0::keys::get_keys::Response as KeyQueryResponse, user_id};
|
||||
use ruma::{api::client::keys::get_keys::v3::Response as KeyQueryResponse, user_id};
|
||||
|
||||
use super::{ReadOnlyOwnUserIdentity, ReadOnlyUserIdentities, ReadOnlyUserIdentity};
|
||||
use crate::{
|
||||
|
||||
@@ -26,14 +26,14 @@ use matrix_sdk_common::{
|
||||
locks::Mutex,
|
||||
};
|
||||
use ruma::{
|
||||
api::client::r0::{
|
||||
api::client::{
|
||||
keys::{
|
||||
claim_keys::{Request as KeysClaimRequest, Response as KeysClaimResponse},
|
||||
get_keys::Response as KeysQueryResponse,
|
||||
claim_keys::v3::{Request as KeysClaimRequest, Response as KeysClaimResponse},
|
||||
get_keys::v3::Response as KeysQueryResponse,
|
||||
upload_keys,
|
||||
upload_signatures::Request as UploadSignaturesRequest,
|
||||
upload_signatures::v3::Request as UploadSignaturesRequest,
|
||||
},
|
||||
sync::sync_events::{DeviceLists, ToDevice},
|
||||
sync::sync_events::v3::{DeviceLists, ToDevice},
|
||||
},
|
||||
assign,
|
||||
events::{
|
||||
@@ -483,7 +483,7 @@ impl OlmMachine {
|
||||
/// performed.
|
||||
async fn receive_keys_upload_response(
|
||||
&self,
|
||||
response: &upload_keys::Response,
|
||||
response: &upload_keys::v3::Response,
|
||||
) -> OlmResult<()> {
|
||||
self.account.receive_keys_upload_response(response).await
|
||||
}
|
||||
@@ -557,14 +557,14 @@ impl OlmMachine {
|
||||
///
|
||||
/// [`receive_keys_upload_response`]: #method.receive_keys_upload_response
|
||||
/// [`OlmMachine`]: struct.OlmMachine.html
|
||||
async fn keys_for_upload(&self) -> Option<upload_keys::Request> {
|
||||
async fn keys_for_upload(&self) -> Option<upload_keys::v3::Request> {
|
||||
let (device_keys, one_time_keys) = self.account.keys_for_upload().await?;
|
||||
|
||||
let device_keys = device_keys
|
||||
.map(|d| Raw::from_json(to_raw_value(&d).expect("Coulnd't serialize device keys")));
|
||||
|
||||
Some(
|
||||
assign!(upload_keys::Request::new(), { device_keys, one_time_keys, fallback_keys: BTreeMap::new(), }),
|
||||
assign!(upload_keys::v3::Request::new(), { device_keys, one_time_keys, fallback_keys: BTreeMap::new(), }),
|
||||
)
|
||||
}
|
||||
|
||||
@@ -1559,7 +1559,7 @@ pub(crate) mod test {
|
||||
use matrix_sdk_test::{async_test, test_json};
|
||||
use ruma::{
|
||||
api::{
|
||||
client::r0::keys::{claim_keys, get_keys, upload_keys},
|
||||
client::keys::{claim_keys, get_keys, upload_keys},
|
||||
IncomingResponse,
|
||||
},
|
||||
device_id,
|
||||
@@ -1607,15 +1607,15 @@ pub(crate) mod test {
|
||||
Response::builder().status(200).body(json.to_string().as_bytes().to_vec()).unwrap()
|
||||
}
|
||||
|
||||
fn keys_upload_response() -> upload_keys::Response {
|
||||
fn keys_upload_response() -> upload_keys::v3::Response {
|
||||
let data = response_from_file(&test_json::KEYS_UPLOAD);
|
||||
upload_keys::Response::try_from_http_response(data)
|
||||
upload_keys::v3::Response::try_from_http_response(data)
|
||||
.expect("Can't parse the keys upload response")
|
||||
}
|
||||
|
||||
fn keys_query_response() -> get_keys::Response {
|
||||
fn keys_query_response() -> get_keys::v3::Response {
|
||||
let data = response_from_file(&test_json::KEYS_QUERY);
|
||||
get_keys::Response::try_from_http_response(data)
|
||||
get_keys::v3::Response::try_from_http_response(data)
|
||||
.expect("Can't parse the keys upload response")
|
||||
}
|
||||
|
||||
@@ -1683,7 +1683,7 @@ pub(crate) mod test {
|
||||
let mut one_time_keys = BTreeMap::new();
|
||||
one_time_keys.insert(bob.user_id().to_owned(), bob_keys);
|
||||
|
||||
let response = claim_keys::Response::new(one_time_keys);
|
||||
let response = claim_keys::v3::Response::new(one_time_keys);
|
||||
|
||||
alice.receive_keys_claim_response(&response).await.unwrap();
|
||||
|
||||
@@ -1915,7 +1915,7 @@ pub(crate) mod test {
|
||||
let mut one_time_keys = BTreeMap::new();
|
||||
one_time_keys.insert(bob_machine.user_id().to_owned(), bob_keys);
|
||||
|
||||
let response = claim_keys::Response::new(one_time_keys);
|
||||
let response = claim_keys::v3::Response::new(one_time_keys);
|
||||
|
||||
alice_machine.receive_keys_claim_response(&response).await.unwrap();
|
||||
|
||||
|
||||
@@ -31,7 +31,10 @@ use olm_rs::{
|
||||
PicklingMode,
|
||||
};
|
||||
use ruma::{
|
||||
api::client::r0::keys::{upload_keys, upload_signatures::Request as SignatureUploadRequest},
|
||||
api::client::keys::{
|
||||
upload_keys,
|
||||
upload_signatures::v3::{Request as SignatureUploadRequest, SignedKeys},
|
||||
},
|
||||
encryption::{CrossSigningKey, DeviceKeys, OneTimeKey, SignedKey},
|
||||
events::{
|
||||
room::encrypted::{
|
||||
@@ -250,7 +253,7 @@ impl Account {
|
||||
|
||||
pub async fn receive_keys_upload_response(
|
||||
&self,
|
||||
response: &upload_keys::Response,
|
||||
response: &upload_keys::v3::Response,
|
||||
) -> OlmResult<()> {
|
||||
if !self.inner.shared() {
|
||||
debug!("Marking account as shared");
|
||||
@@ -829,17 +832,15 @@ impl ReadOnlyAccount {
|
||||
master_key: MasterPubkey,
|
||||
) -> Result<SignatureUploadRequest, SignatureError> {
|
||||
let public_key =
|
||||
master_key.get_first_key().ok_or(SignatureError::MissingSigningKey)?.to_string();
|
||||
master_key.get_first_key().ok_or(SignatureError::MissingSigningKey)?.into();
|
||||
let mut cross_signing_key: CrossSigningKey = master_key.into();
|
||||
cross_signing_key.signatures.clear();
|
||||
self.sign_cross_signing_key(&mut cross_signing_key).await?;
|
||||
|
||||
let mut signed_keys = BTreeMap::new();
|
||||
signed_keys
|
||||
.entry(self.user_id().to_owned())
|
||||
.or_insert_with(BTreeMap::new)
|
||||
.insert(public_key, serde_json::to_value(cross_signing_key)?);
|
||||
let mut user_signed_keys = SignedKeys::new();
|
||||
user_signed_keys.add_cross_signing_keys(public_key, Raw::new(&cross_signing_key)?);
|
||||
|
||||
let signed_keys = [(self.user_id().to_owned(), user_signed_keys)].into();
|
||||
Ok(SignatureUploadRequest::new(signed_keys))
|
||||
}
|
||||
|
||||
|
||||
@@ -14,20 +14,18 @@
|
||||
|
||||
mod pk_signing;
|
||||
|
||||
use std::{
|
||||
collections::BTreeMap,
|
||||
sync::{
|
||||
atomic::{AtomicBool, Ordering},
|
||||
Arc,
|
||||
},
|
||||
use std::sync::{
|
||||
atomic::{AtomicBool, Ordering},
|
||||
Arc,
|
||||
};
|
||||
|
||||
use matrix_sdk_common::locks::Mutex;
|
||||
use pk_signing::{MasterSigning, PickledSignings, SelfSigning, Signing, SigningError, UserSigning};
|
||||
use ruma::{
|
||||
api::client::r0::keys::upload_signatures::Request as SignatureUploadRequest,
|
||||
api::client::keys::upload_signatures::v3::{Request as SignatureUploadRequest, SignedKeys},
|
||||
encryption::{DeviceKeys, KeyUsage},
|
||||
events::secret::request::SecretName,
|
||||
serde::Raw,
|
||||
UserId,
|
||||
};
|
||||
use serde::{Deserialize, Serialize};
|
||||
@@ -404,17 +402,17 @@ impl PrivateCrossSigningIdentity {
|
||||
.sign_user(user_identity)
|
||||
.await?;
|
||||
|
||||
let mut signed_keys = BTreeMap::new();
|
||||
|
||||
signed_keys.entry(user_identity.user_id().to_owned()).or_insert_with(BTreeMap::new).insert(
|
||||
let mut user_signed_keys = SignedKeys::new();
|
||||
user_signed_keys.add_cross_signing_keys(
|
||||
user_identity
|
||||
.master_key()
|
||||
.get_first_key()
|
||||
.ok_or(SignatureError::MissingSigningKey)?
|
||||
.to_owned(),
|
||||
serde_json::to_value(master_key)?,
|
||||
.into(),
|
||||
Raw::new(&master_key)?,
|
||||
);
|
||||
|
||||
let signed_keys = [(user_identity.user_id().to_owned(), user_signed_keys)].into();
|
||||
Ok(SignatureUploadRequest::new(signed_keys))
|
||||
}
|
||||
|
||||
@@ -449,12 +447,10 @@ impl PrivateCrossSigningIdentity {
|
||||
.sign_device(device_keys)
|
||||
.await?;
|
||||
|
||||
let mut signed_keys = BTreeMap::new();
|
||||
signed_keys
|
||||
.entry((*self.user_id).to_owned())
|
||||
.or_insert_with(BTreeMap::new)
|
||||
.insert(device_keys.device_id.to_string(), serde_json::to_value(device_keys)?);
|
||||
let mut user_signed_keys = SignedKeys::new();
|
||||
user_signed_keys.add_device_keys(device_keys.device_id.clone(), Raw::new(device_keys)?);
|
||||
|
||||
let signed_keys = [((*self.user_id).to_owned(), user_signed_keys)].into();
|
||||
Ok(SignatureUploadRequest::new(signed_keys))
|
||||
}
|
||||
|
||||
|
||||
@@ -15,19 +15,19 @@
|
||||
use std::{collections::BTreeMap, iter, sync::Arc, time::Duration};
|
||||
|
||||
use ruma::{
|
||||
api::client::r0::{
|
||||
backup::{add_backup_keys::Response as KeysBackupResponse, RoomKeyBackup},
|
||||
api::client::{
|
||||
backup::{add_backup_keys::v3::Response as KeysBackupResponse, RoomKeyBackup},
|
||||
keys::{
|
||||
claim_keys::{Request as KeysClaimRequest, Response as KeysClaimResponse},
|
||||
get_keys::Response as KeysQueryResponse,
|
||||
upload_keys::{Request as KeysUploadRequest, Response as KeysUploadResponse},
|
||||
upload_signatures::{
|
||||
claim_keys::v3::{Request as KeysClaimRequest, Response as KeysClaimResponse},
|
||||
get_keys::v3::Response as KeysQueryResponse,
|
||||
upload_keys::v3::{Request as KeysUploadRequest, Response as KeysUploadResponse},
|
||||
upload_signatures::v3::{
|
||||
Request as SignatureUploadRequest, Response as SignatureUploadResponse,
|
||||
},
|
||||
upload_signing_keys::Response as SigningKeysUploadResponse,
|
||||
upload_signing_keys::v3::Response as SigningKeysUploadResponse,
|
||||
},
|
||||
message::send_message_event::Response as RoomMessageResponse,
|
||||
to_device::send_event_to_device::Response as ToDeviceResponse,
|
||||
message::send_message_event::v3::Response as RoomMessageResponse,
|
||||
to_device::send_event_to_device::v3::Response as ToDeviceResponse,
|
||||
},
|
||||
encryption::CrossSigningKey,
|
||||
events::{AnyMessageEventContent, AnyToDeviceEventContent, EventContent, EventType},
|
||||
@@ -38,7 +38,7 @@ use ruma::{
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
/// Customized version of
|
||||
/// `ruma_client_api::r0::to_device::send_event_to_device::Request`
|
||||
/// `ruma_client_api::to_device::send_event_to_device::v3::Request`
|
||||
#[derive(Clone, Debug, Deserialize, Serialize)]
|
||||
pub struct ToDeviceRequest {
|
||||
/// Type of event being sent to each device.
|
||||
@@ -144,7 +144,7 @@ pub struct UploadSigningKeysRequest {
|
||||
}
|
||||
|
||||
/// Customized version of
|
||||
/// `ruma_client_api::r0::keys::get_keys::Request`, without any
|
||||
/// `ruma_client_api::keys::get_keys::v3::Request`, without any
|
||||
/// references.
|
||||
#[derive(Clone, Debug)]
|
||||
pub struct KeysQueryRequest {
|
||||
|
||||
@@ -592,7 +592,7 @@ mod test {
|
||||
use matrix_sdk_test::{async_test, response_from_file};
|
||||
use ruma::{
|
||||
api::{
|
||||
client::r0::keys::{claim_keys, get_keys},
|
||||
client::keys::{claim_keys, get_keys},
|
||||
IncomingResponse,
|
||||
},
|
||||
device_id, room_id, user_id, DeviceId, TransactionId, UserId,
|
||||
@@ -609,19 +609,19 @@ mod test {
|
||||
device_id!("JLAFKJWSCS")
|
||||
}
|
||||
|
||||
fn keys_query_response() -> get_keys::Response {
|
||||
fn keys_query_response() -> get_keys::v3::Response {
|
||||
let data = include_bytes!("../../benches/keys_query.json");
|
||||
let data: Value = serde_json::from_slice(data).unwrap();
|
||||
let data = response_from_file(&data);
|
||||
get_keys::Response::try_from_http_response(data)
|
||||
get_keys::v3::Response::try_from_http_response(data)
|
||||
.expect("Can't parse the keys upload response")
|
||||
}
|
||||
|
||||
fn keys_claim_response() -> claim_keys::Response {
|
||||
fn keys_claim_response() -> claim_keys::v3::Response {
|
||||
let data = include_bytes!("../../benches/keys_claim.json");
|
||||
let data: Value = serde_json::from_slice(data).unwrap();
|
||||
let data = response_from_file(&data);
|
||||
claim_keys::Response::try_from_http_response(data)
|
||||
claim_keys::v3::Response::try_from_http_response(data)
|
||||
.expect("Can't parse the keys upload response")
|
||||
}
|
||||
|
||||
|
||||
@@ -20,7 +20,7 @@ use std::{
|
||||
|
||||
use dashmap::{DashMap, DashSet};
|
||||
use ruma::{
|
||||
api::client::r0::keys::claim_keys::{
|
||||
api::client::keys::claim_keys::v3::{
|
||||
Request as KeysClaimRequest, Response as KeysClaimResponse,
|
||||
},
|
||||
assign,
|
||||
@@ -338,7 +338,7 @@ mod test {
|
||||
use matrix_sdk_common::locks::Mutex;
|
||||
use matrix_sdk_test::async_test;
|
||||
use ruma::{
|
||||
api::client::r0::keys::claim_keys::Response as KeyClaimResponse, device_id, user_id,
|
||||
api::client::keys::claim_keys::v3::Response as KeyClaimResponse, device_id, user_id,
|
||||
DeviceId, UserId,
|
||||
};
|
||||
|
||||
|
||||
@@ -251,8 +251,9 @@ impl VerificationMachine {
|
||||
let event = ToDeviceEvent { content, sender: self.own_user_id().to_owned() };
|
||||
|
||||
events.push(
|
||||
Raw::new(&AnyToDeviceEvent::KeyVerificationCancel(event))
|
||||
.expect("Failed to serialize m.key_verification.cancel event"),
|
||||
Raw::new(&event)
|
||||
.expect("Failed to serialize m.key_verification.cancel event")
|
||||
.cast(),
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -36,7 +36,7 @@ use ruma::events::key::verification::done::{
|
||||
KeyVerificationDoneEventContent, ToDeviceKeyVerificationDoneEventContent,
|
||||
};
|
||||
use ruma::{
|
||||
api::client::r0::keys::upload_signatures::Request as SignatureUploadRequest,
|
||||
api::client::keys::upload_signatures::v3::Request as SignatureUploadRequest,
|
||||
events::{
|
||||
key::verification::{
|
||||
cancel::{
|
||||
|
||||
@@ -19,7 +19,7 @@ use matrix_qrcode::{
|
||||
SelfVerificationNoMasterKey, VerificationData,
|
||||
};
|
||||
use ruma::{
|
||||
api::client::r0::keys::upload_signatures::Request as SignatureUploadRequest,
|
||||
api::client::keys::upload_signatures::v3::Request as SignatureUploadRequest,
|
||||
events::{
|
||||
key::verification::{
|
||||
cancel::CancelCode,
|
||||
|
||||
@@ -22,7 +22,7 @@ use inner_sas::InnerSas;
|
||||
#[cfg(test)]
|
||||
use matrix_sdk_common::instant::Instant;
|
||||
use ruma::{
|
||||
api::client::r0::keys::upload_signatures::Request as SignatureUploadRequest,
|
||||
api::client::keys::upload_signatures::v3::Request as SignatureUploadRequest,
|
||||
events::{
|
||||
key::verification::{cancel::CancelCode, ShortAuthenticationString},
|
||||
AnyMessageEventContent, AnyToDeviceEventContent,
|
||||
|
||||
@@ -18,10 +18,6 @@ appservice = []
|
||||
http = "0.2.4"
|
||||
lazy_static = "1.4.0"
|
||||
matrix-sdk-test-macros = { version = "0.1.0", path = "../matrix-sdk-test-macros" }
|
||||
ruma = { version = "0.5.0", features = ["client-api-c"] }
|
||||
serde = "1.0.126"
|
||||
serde_json = "1.0.64"
|
||||
|
||||
[dependencies.ruma]
|
||||
git = "https://github.com/ruma/ruma/"
|
||||
rev = "b9f32bc6327542d382d4eb42ec43623495c50e66"
|
||||
features = ["client-api-c"]
|
||||
|
||||
@@ -3,7 +3,7 @@ use std::{collections::HashMap, panic};
|
||||
use http::Response;
|
||||
pub use matrix_sdk_test_macros::async_test;
|
||||
use ruma::{
|
||||
api::{client::r0::sync::sync_events::Response as SyncResponse, IncomingResponse},
|
||||
api::{client::sync::sync_events::v3::Response as SyncResponse, IncomingResponse},
|
||||
events::{
|
||||
presence::PresenceEvent, AnyGlobalAccountDataEvent, AnySyncEphemeralRoomEvent,
|
||||
AnySyncRoomEvent, AnySyncStateEvent,
|
||||
|
||||
@@ -99,8 +99,7 @@ version = "0.11.3"
|
||||
default_features = false
|
||||
|
||||
[dependencies.ruma]
|
||||
git = "https://github.com/ruma/ruma/"
|
||||
rev = "b9f32bc6327542d382d4eb42ec43623495c50e66"
|
||||
version = "0.5.0"
|
||||
features = ["client-api-c", "compat", "rand", "unstable-msc2448", "unstable-pre-spec"]
|
||||
|
||||
[dependencies.tokio-stream]
|
||||
|
||||
@@ -15,11 +15,14 @@ async fn bootstrap(client: Client, user_id: Box<UserId>, password: String) {
|
||||
io::stdin().read_line(&mut input).expect("error: unable to read user input");
|
||||
|
||||
if let Err(e) = client.bootstrap_cross_signing(None).await {
|
||||
use matrix_sdk::ruma::{api::client::r0::uiaa, assign};
|
||||
use matrix_sdk::ruma::{api::client::uiaa, assign};
|
||||
|
||||
if let Some(response) = e.uiaa_response() {
|
||||
let auth_data = uiaa::AuthData::Password(assign!(
|
||||
uiaa::Password::new(uiaa::UserIdentifier::MatrixId(user_id.as_str()), &password),
|
||||
uiaa::Password::new(
|
||||
uiaa::UserIdentifier::UserIdOrLocalpart(user_id.as_str()),
|
||||
&password,
|
||||
),
|
||||
{ session: response.session.as_deref() }
|
||||
));
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
use std::{env, process::exit};
|
||||
|
||||
use matrix_sdk::{
|
||||
ruma::{api::client::r0::profile, MxcUri, UserId},
|
||||
ruma::{api::client::profile, MxcUri, UserId},
|
||||
Client, Result as MatrixResult,
|
||||
};
|
||||
use url::Url;
|
||||
@@ -19,7 +19,7 @@ struct UserProfile {
|
||||
async fn get_profile(client: Client, mxid: &UserId) -> MatrixResult<UserProfile> {
|
||||
// First construct the request you want to make
|
||||
// See https://docs.rs/ruma-client-api/0.9.0/ruma_client_api/index.html for all available Endpoints
|
||||
let request = profile::get_profile::Request::new(mxid);
|
||||
let request = profile::get_profile::v3::Request::new(mxid);
|
||||
|
||||
// Start the request using matrix_sdk::Client::send
|
||||
let resp = client.send(request, None).await?;
|
||||
|
||||
@@ -19,7 +19,7 @@ use std::io::Read;
|
||||
use matrix_sdk_base::media::{MediaFormat, MediaRequest, MediaType};
|
||||
use mime::Mime;
|
||||
use ruma::{
|
||||
api::client::r0::{
|
||||
api::client::{
|
||||
account::{
|
||||
add_3pid, change_password, deactivate, delete_3pid, get_3pids,
|
||||
request_3pid_management_token_via_email, request_3pid_management_token_via_msisdn,
|
||||
@@ -70,7 +70,7 @@ impl Account {
|
||||
/// ```
|
||||
pub async fn get_display_name(&self) -> Result<Option<String>> {
|
||||
let user_id = self.client.user_id().await.ok_or(Error::AuthenticationRequired)?;
|
||||
let request = get_display_name::Request::new(&user_id);
|
||||
let request = get_display_name::v3::Request::new(&user_id);
|
||||
let response = self.client.send(request, None).await?;
|
||||
Ok(response.displayname)
|
||||
}
|
||||
@@ -93,7 +93,7 @@ impl Account {
|
||||
/// ```
|
||||
pub async fn set_display_name(&self, name: Option<&str>) -> Result<()> {
|
||||
let user_id = self.client.user_id().await.ok_or(Error::AuthenticationRequired)?;
|
||||
let request = set_display_name::Request::new(&user_id, name);
|
||||
let request = set_display_name::v3::Request::new(&user_id, name);
|
||||
self.client.send(request, None).await?;
|
||||
Ok(())
|
||||
}
|
||||
@@ -118,7 +118,7 @@ impl Account {
|
||||
/// ```
|
||||
pub async fn get_avatar_url(&self) -> Result<Option<Box<MxcUri>>> {
|
||||
let user_id = self.client.user_id().await.ok_or(Error::AuthenticationRequired)?;
|
||||
let request = get_avatar_url::Request::new(&user_id);
|
||||
let request = get_avatar_url::v3::Request::new(&user_id);
|
||||
|
||||
let config = Some(RequestConfig::new().force_auth());
|
||||
|
||||
@@ -131,7 +131,7 @@ impl Account {
|
||||
/// The avatar is unset if `url` is `None`.
|
||||
pub async fn set_avatar_url(&self, url: Option<&MxcUri>) -> Result<()> {
|
||||
let user_id = self.client.user_id().await.ok_or(Error::AuthenticationRequired)?;
|
||||
let request = set_avatar_url::Request::new(&user_id, url);
|
||||
let request = set_avatar_url::v3::Request::new(&user_id, url);
|
||||
self.client.send(request, None).await?;
|
||||
Ok(())
|
||||
}
|
||||
@@ -231,9 +231,9 @@ impl Account {
|
||||
/// }
|
||||
/// # Result::<_, matrix_sdk::Error>::Ok(()) });
|
||||
/// ```
|
||||
pub async fn get_profile(&self) -> Result<get_profile::Response> {
|
||||
pub async fn get_profile(&self) -> Result<get_profile::v3::Response> {
|
||||
let user_id = self.client.user_id().await.ok_or(Error::AuthenticationRequired)?;
|
||||
let request = get_profile::Request::new(&user_id);
|
||||
let request = get_profile::v3::Request::new(&user_id);
|
||||
Ok(self.client.send(request, None).await?)
|
||||
}
|
||||
|
||||
@@ -260,8 +260,8 @@ impl Account {
|
||||
/// # use std::convert::TryFrom;
|
||||
/// # use matrix_sdk::Client;
|
||||
/// # use matrix_sdk::ruma::{
|
||||
/// # api::client::r0::{
|
||||
/// # account::change_password::{Request as ChangePasswordRequest},
|
||||
/// # api::client::{
|
||||
/// # account::change_password::v3::{Request as ChangePasswordRequest},
|
||||
/// # uiaa::{AuthData, Dummy},
|
||||
/// # },
|
||||
/// # assign,
|
||||
@@ -278,14 +278,14 @@ impl Account {
|
||||
/// # Result::<_, matrix_sdk::Error>::Ok(()) });
|
||||
/// ```
|
||||
/// [uiaa]: https://spec.matrix.org/v1.2/client-server-api/#user-interactive-authentication-api
|
||||
/// [`UiaaResponse`]: ruma::api::client::r0::uiaa::UiaaResponse
|
||||
/// [`UiaaResponse`]: ruma::api::client::uiaa::UiaaResponse
|
||||
/// [`ErrorKind::WeakPassword`]: ruma::api::client::error::ErrorKind::WeakPassword
|
||||
pub async fn change_password(
|
||||
&self,
|
||||
new_password: &str,
|
||||
auth_data: Option<AuthData<'_>>,
|
||||
) -> Result<change_password::Response> {
|
||||
let request = assign!(change_password::Request::new(new_password), {
|
||||
) -> Result<change_password::v3::Response> {
|
||||
let request = assign!(change_password::v3::Request::new(new_password), {
|
||||
auth: auth_data,
|
||||
});
|
||||
Ok(self.client.send(request, None).await?)
|
||||
@@ -309,8 +309,8 @@ impl Account {
|
||||
/// # use std::convert::TryFrom;
|
||||
/// # use matrix_sdk::Client;
|
||||
/// # use matrix_sdk::ruma::{
|
||||
/// # api::client::r0::{
|
||||
/// # account::change_password::{Request as ChangePasswordRequest},
|
||||
/// # api::client::{
|
||||
/// # account::change_password::v3::{Request as ChangePasswordRequest},
|
||||
/// # uiaa::{AuthData, Dummy},
|
||||
/// # },
|
||||
/// # assign,
|
||||
@@ -329,13 +329,13 @@ impl Account {
|
||||
/// ```
|
||||
/// [3pid]: https://spec.matrix.org/v1.2/appendices/#3pid-types
|
||||
/// [uiaa]: https://spec.matrix.org/v1.2/client-server-api/#user-interactive-authentication-api
|
||||
/// [`UiaaResponse`]: ruma::api::client::r0::uiaa::UiaaResponse
|
||||
/// [`UiaaResponse`]: ruma::api::client::uiaa::UiaaResponse
|
||||
pub async fn deactivate(
|
||||
&self,
|
||||
id_server: Option<&str>,
|
||||
auth_data: Option<AuthData<'_>>,
|
||||
) -> Result<deactivate::Response> {
|
||||
let request = assign!(deactivate::Request::new(), {
|
||||
) -> Result<deactivate::v3::Response> {
|
||||
let request = assign!(deactivate::v3::Request::new(), {
|
||||
id_server,
|
||||
auth: auth_data,
|
||||
});
|
||||
@@ -364,8 +364,8 @@ impl Account {
|
||||
/// # Result::<_, matrix_sdk::Error>::Ok(()) });
|
||||
/// ```
|
||||
/// [3pid]: https://spec.matrix.org/v1.2/appendices/#3pid-types
|
||||
pub async fn get_3pids(&self) -> Result<get_3pids::Response> {
|
||||
let request = get_3pids::Request::new();
|
||||
pub async fn get_3pids(&self) -> Result<get_3pids::v3::Response> {
|
||||
let request = get_3pids::v3::Request::new();
|
||||
Ok(self.client.send(request, None).await?)
|
||||
}
|
||||
|
||||
@@ -438,8 +438,8 @@ impl Account {
|
||||
client_secret: &ClientSecret,
|
||||
email: &str,
|
||||
send_attempt: UInt,
|
||||
) -> Result<request_3pid_management_token_via_email::Response> {
|
||||
let request = request_3pid_management_token_via_email::Request::new(
|
||||
) -> Result<request_3pid_management_token_via_email::v3::Response> {
|
||||
let request = request_3pid_management_token_via_email::v3::Request::new(
|
||||
client_secret,
|
||||
email,
|
||||
send_attempt,
|
||||
@@ -521,8 +521,8 @@ impl Account {
|
||||
country: &str,
|
||||
phone_number: &str,
|
||||
send_attempt: UInt,
|
||||
) -> Result<request_3pid_management_token_via_msisdn::Response> {
|
||||
let request = request_3pid_management_token_via_msisdn::Request::new(
|
||||
) -> Result<request_3pid_management_token_via_msisdn::v3::Response> {
|
||||
let request = request_3pid_management_token_via_msisdn::v3::Request::new(
|
||||
client_secret,
|
||||
country,
|
||||
phone_number,
|
||||
@@ -559,14 +559,14 @@ impl Account {
|
||||
///
|
||||
/// [3pid]: https://spec.matrix.org/v1.2/appendices/#3pid-types
|
||||
/// [uiaa]: https://spec.matrix.org/v1.2/client-server-api/#user-interactive-authentication-api
|
||||
/// [`UiaaResponse`]: ruma::api::client::r0::uiaa::UiaaResponse
|
||||
/// [`UiaaResponse`]: ruma::api::client::uiaa::UiaaResponse
|
||||
pub async fn add_3pid(
|
||||
&self,
|
||||
client_secret: &ClientSecret,
|
||||
sid: &SessionId,
|
||||
auth_data: Option<AuthData<'_>>,
|
||||
) -> Result<add_3pid::Response> {
|
||||
let request = assign!(add_3pid::Request::new(client_secret, sid), {
|
||||
) -> Result<add_3pid::v3::Response> {
|
||||
let request = assign!(add_3pid::v3::Request::new(client_secret, sid), {
|
||||
auth: auth_data,
|
||||
});
|
||||
Ok(self.client.send(request, None).await?)
|
||||
@@ -599,7 +599,7 @@ impl Account {
|
||||
/// # use futures::executor::block_on;
|
||||
/// # use matrix_sdk::Client;
|
||||
/// # use matrix_sdk::ruma::thirdparty::Medium;
|
||||
/// # use matrix_sdk::ruma::api::client::r0::account::ThirdPartyIdRemovalStatus;
|
||||
/// # use matrix_sdk::ruma::api::client::account::ThirdPartyIdRemovalStatus;
|
||||
/// # use url::Url;
|
||||
/// # block_on(async {
|
||||
/// # let homeserver = Url::parse("http://localhost:8080")?;
|
||||
@@ -619,15 +619,15 @@ impl Account {
|
||||
/// # Result::<_, matrix_sdk::Error>::Ok(()) });
|
||||
/// ```
|
||||
/// [3pid]: https://spec.matrix.org/v1.2/appendices/#3pid-types
|
||||
/// [`ThirdPartyIdRemovalStatus::Success`]: ruma::api::client::r0::account::ThirdPartyIdRemovalStatus::Success
|
||||
/// [`ThirdPartyIdRemovalStatus::NoSupport`]: ruma::api::client::r0::account::ThirdPartyIdRemovalStatus::NoSupport
|
||||
/// [`ThirdPartyIdRemovalStatus::Success`]: ruma::api::client::account::ThirdPartyIdRemovalStatus::Success
|
||||
/// [`ThirdPartyIdRemovalStatus::NoSupport`]: ruma::api::client::account::ThirdPartyIdRemovalStatus::NoSupport
|
||||
pub async fn delete_3pid(
|
||||
&self,
|
||||
address: &str,
|
||||
medium: Medium,
|
||||
id_server: Option<&str>,
|
||||
) -> Result<delete_3pid::Response> {
|
||||
let request = assign!(delete_3pid::Request::new(medium, address), {
|
||||
) -> Result<delete_3pid::v3::Response> {
|
||||
let request = assign!(delete_3pid::v3::Request::new(medium, address), {
|
||||
id_server: id_server,
|
||||
});
|
||||
Ok(self.client.send(request, None).await?)
|
||||
|
||||
@@ -41,25 +41,22 @@ use ruma::TransactionId;
|
||||
use ruma::{
|
||||
api::{
|
||||
client::{
|
||||
r0::{
|
||||
account::{register, whoami},
|
||||
capabilities::{get_capabilities, Capabilities},
|
||||
device::{delete_devices, get_devices},
|
||||
directory::{get_public_rooms, get_public_rooms_filtered},
|
||||
filter::{create_filter::Request as FilterUploadRequest, FilterDefinition},
|
||||
media::{create_content, get_content, get_content_thumbnail},
|
||||
membership::{join_room_by_id, join_room_by_id_or_alias},
|
||||
push::get_notifications::Notification,
|
||||
room::create_room,
|
||||
session::{get_login_types, login, sso_login},
|
||||
sync::sync_events,
|
||||
uiaa::{AuthData, UserIdentifier},
|
||||
},
|
||||
session::sso_login_with_provider::v3 as sso_login_with_provider,
|
||||
unversioned::{discover_homeserver, get_supported_versions},
|
||||
account::{register, whoami},
|
||||
capabilities::{get_capabilities, Capabilities},
|
||||
device::{delete_devices, get_devices},
|
||||
directory::{get_public_rooms, get_public_rooms_filtered},
|
||||
discover::{discover_homeserver, get_supported_versions},
|
||||
filter::{create_filter::v3::Request as FilterUploadRequest, FilterDefinition},
|
||||
media::{create_content, get_content, get_content_thumbnail},
|
||||
membership::{join_room_by_id, join_room_by_id_or_alias},
|
||||
push::get_notifications::v3::Notification,
|
||||
room::create_room,
|
||||
session::{get_login_types, login, sso_login, sso_login_with_provider},
|
||||
sync::sync_events,
|
||||
uiaa::{AuthData, UserIdentifier},
|
||||
},
|
||||
error::FromHttpResponseError,
|
||||
OutgoingRequest, SendAccessToken,
|
||||
MatrixVersion, OutgoingRequest, SendAccessToken,
|
||||
},
|
||||
assign,
|
||||
presence::PresenceState,
|
||||
@@ -367,7 +364,7 @@ impl Client {
|
||||
/// # Result::<_, anyhow::Error>::Ok(()) });
|
||||
/// ```
|
||||
pub async fn get_capabilities(&self) -> HttpResult<Capabilities> {
|
||||
let res = self.send(get_capabilities::Request::new(), None).await?;
|
||||
let res = self.send(get_capabilities::v3::Request::new(), None).await?;
|
||||
Ok(res.capabilities)
|
||||
}
|
||||
|
||||
@@ -722,8 +719,8 @@ impl Client {
|
||||
///
|
||||
/// This should be the first step when trying to login so you can call the
|
||||
/// appropriate method for the next step.
|
||||
pub async fn get_login_types(&self) -> HttpResult<get_login_types::Response> {
|
||||
let request = get_login_types::Request::new();
|
||||
pub async fn get_login_types(&self) -> HttpResult<get_login_types::v3::Response> {
|
||||
let request = get_login_types::v3::Request::new();
|
||||
self.send(request, None).await
|
||||
}
|
||||
|
||||
@@ -751,11 +748,20 @@ impl Client {
|
||||
let homeserver = self.homeserver().await;
|
||||
|
||||
let request = if let Some(id) = idp_id {
|
||||
sso_login_with_provider::Request::new(id, redirect_url)
|
||||
.try_into_http_request::<Vec<u8>>(homeserver.as_str(), SendAccessToken::None)
|
||||
sso_login_with_provider::v3::Request::new(id, redirect_url)
|
||||
.try_into_http_request::<Vec<u8>>(
|
||||
homeserver.as_str(),
|
||||
SendAccessToken::None,
|
||||
// FIXME: Use versions reported by server
|
||||
&[MatrixVersion::V1_0],
|
||||
)
|
||||
} else {
|
||||
sso_login::Request::new(redirect_url)
|
||||
.try_into_http_request::<Vec<u8>>(homeserver.as_str(), SendAccessToken::None)
|
||||
sso_login::v3::Request::new(redirect_url).try_into_http_request::<Vec<u8>>(
|
||||
homeserver.as_str(),
|
||||
SendAccessToken::None,
|
||||
// FIXME: Use versions reported by server
|
||||
&[MatrixVersion::V1_0],
|
||||
)
|
||||
};
|
||||
|
||||
match request {
|
||||
@@ -816,16 +822,16 @@ impl Client {
|
||||
password: &str,
|
||||
device_id: Option<&str>,
|
||||
initial_device_display_name: Option<&str>,
|
||||
) -> Result<login::Response> {
|
||||
) -> Result<login::v3::Response> {
|
||||
let homeserver = self.homeserver().await;
|
||||
info!(homeserver = homeserver.as_str(), user = user.as_ref(), "Logging in");
|
||||
|
||||
let login_info = login::LoginInfo::Password(login::Password::new(
|
||||
UserIdentifier::MatrixId(user.as_ref()),
|
||||
let login_info = login::v3::LoginInfo::Password(login::v3::Password::new(
|
||||
UserIdentifier::UserIdOrLocalpart(user.as_ref()),
|
||||
password,
|
||||
));
|
||||
|
||||
let request = assign!(login::Request::new(login_info), {
|
||||
let request = assign!(login::v3::Request::new(login_info), {
|
||||
device_id: device_id.map(|d| d.into()),
|
||||
initial_device_display_name,
|
||||
});
|
||||
@@ -927,7 +933,7 @@ impl Client {
|
||||
device_id: Option<&str>,
|
||||
initial_device_display_name: Option<&str>,
|
||||
idp_id: Option<&str>,
|
||||
) -> Result<login::Response>
|
||||
) -> Result<login::v3::Response>
|
||||
where
|
||||
C: Future<Output = Result<()>>,
|
||||
{
|
||||
@@ -1101,12 +1107,12 @@ impl Client {
|
||||
token: &str,
|
||||
device_id: Option<&str>,
|
||||
initial_device_display_name: Option<&str>,
|
||||
) -> Result<login::Response> {
|
||||
) -> Result<login::v3::Response> {
|
||||
info!("Logging in to {}", self.homeserver().await);
|
||||
|
||||
let request = assign!(
|
||||
login::Request::new(
|
||||
login::LoginInfo::Token(login::Token::new(token)),
|
||||
login::v3::Request::new(
|
||||
login::v3::LoginInfo::Token(login::v3::Token::new(token)),
|
||||
), {
|
||||
device_id: device_id.map(|d| d.into()),
|
||||
initial_device_display_name,
|
||||
@@ -1125,7 +1131,7 @@ impl Client {
|
||||
/// # Arguments
|
||||
///
|
||||
/// * `response` - A successful login response.
|
||||
async fn receive_login_response(&self, response: &login::Response) -> Result<()> {
|
||||
async fn receive_login_response(&self, response: &login::v3::Response) -> Result<()> {
|
||||
if self.inner.use_discovery_response {
|
||||
if let Some(well_known) = &response.well_known {
|
||||
if let Ok(homeserver) = Url::parse(&well_known.homeserver.base_url) {
|
||||
@@ -1205,7 +1211,7 @@ impl Client {
|
||||
/// # Arguments
|
||||
///
|
||||
/// * `registration` - The easiest way to create this request is using the
|
||||
/// `register::Request`
|
||||
/// [`register::v3::Request`]
|
||||
/// itself.
|
||||
///
|
||||
///
|
||||
@@ -1214,8 +1220,8 @@ impl Client {
|
||||
/// # use std::convert::TryFrom;
|
||||
/// # use matrix_sdk::Client;
|
||||
/// # use matrix_sdk::ruma::{
|
||||
/// # api::client::r0::{
|
||||
/// # account::register::{Request as RegistrationRequest, RegistrationKind},
|
||||
/// # api::client::{
|
||||
/// # account::register::{v3::Request as RegistrationRequest, RegistrationKind},
|
||||
/// # uiaa,
|
||||
/// # },
|
||||
/// # assign, DeviceId,
|
||||
@@ -1239,8 +1245,8 @@ impl Client {
|
||||
#[instrument(skip(registration))]
|
||||
pub async fn register(
|
||||
&self,
|
||||
registration: impl Into<register::Request<'_>>,
|
||||
) -> HttpResult<register::Response> {
|
||||
registration: impl Into<register::v3::Request<'_>>,
|
||||
) -> HttpResult<register::v3::Response> {
|
||||
let homeserver = self.homeserver().await;
|
||||
info!("Registering to {}", homeserver);
|
||||
|
||||
@@ -1272,11 +1278,11 @@ impl Client {
|
||||
/// ```no_run
|
||||
/// # use matrix_sdk::{
|
||||
/// # Client, config::SyncSettings,
|
||||
/// # ruma::api::client::r0::{
|
||||
/// # ruma::api::client::{
|
||||
/// # filter::{
|
||||
/// # FilterDefinition, LazyLoadOptions, RoomEventFilter, RoomFilter,
|
||||
/// # },
|
||||
/// # sync::sync_events::Filter,
|
||||
/// # sync::sync_events::v3::Filter,
|
||||
/// # }
|
||||
/// # };
|
||||
/// # use futures::executor::block_on;
|
||||
@@ -1331,8 +1337,11 @@ impl Client {
|
||||
/// # Arguments
|
||||
///
|
||||
/// * `room_id` - The `RoomId` of the room to be joined.
|
||||
pub async fn join_room_by_id(&self, room_id: &RoomId) -> HttpResult<join_room_by_id::Response> {
|
||||
let request = join_room_by_id::Request::new(room_id);
|
||||
pub async fn join_room_by_id(
|
||||
&self,
|
||||
room_id: &RoomId,
|
||||
) -> HttpResult<join_room_by_id::v3::Response> {
|
||||
let request = join_room_by_id::v3::Request::new(room_id);
|
||||
self.send(request, None).await
|
||||
}
|
||||
|
||||
@@ -1349,8 +1358,8 @@ impl Client {
|
||||
&self,
|
||||
alias: &RoomOrAliasId,
|
||||
server_names: &[Box<ServerName>],
|
||||
) -> HttpResult<join_room_by_id_or_alias::Response> {
|
||||
let request = assign!(join_room_by_id_or_alias::Request::new(alias), {
|
||||
) -> HttpResult<join_room_by_id_or_alias::v3::Response> {
|
||||
let request = assign!(join_room_by_id_or_alias::v3::Request::new(alias), {
|
||||
server_name: server_names,
|
||||
});
|
||||
self.send(request, None).await
|
||||
@@ -1392,10 +1401,10 @@ impl Client {
|
||||
limit: Option<u32>,
|
||||
since: Option<&str>,
|
||||
server: Option<&ServerName>,
|
||||
) -> HttpResult<get_public_rooms::Response> {
|
||||
) -> HttpResult<get_public_rooms::v3::Response> {
|
||||
let limit = limit.map(UInt::from);
|
||||
|
||||
let request = assign!(get_public_rooms::Request::new(), {
|
||||
let request = assign!(get_public_rooms::v3::Request::new(), {
|
||||
limit,
|
||||
since,
|
||||
server,
|
||||
@@ -1416,8 +1425,8 @@ impl Client {
|
||||
/// # Examples
|
||||
/// ```no_run
|
||||
/// use matrix_sdk::Client;
|
||||
/// # use matrix_sdk::ruma::api::client::r0::room::{
|
||||
/// # create_room::Request as CreateRoomRequest,
|
||||
/// # use matrix_sdk::ruma::api::client::room::{
|
||||
/// # create_room::v3::Request as CreateRoomRequest,
|
||||
/// # Visibility,
|
||||
/// # };
|
||||
/// # use url::Url;
|
||||
@@ -1432,8 +1441,8 @@ impl Client {
|
||||
/// ```
|
||||
pub async fn create_room(
|
||||
&self,
|
||||
room: impl Into<create_room::Request<'_>>,
|
||||
) -> HttpResult<create_room::Response> {
|
||||
room: impl Into<create_room::v3::Request<'_>>,
|
||||
) -> HttpResult<create_room::v3::Response> {
|
||||
let request = room.into();
|
||||
self.send(request, None).await
|
||||
}
|
||||
@@ -1455,7 +1464,7 @@ impl Client {
|
||||
/// # let homeserver = Url::parse("http://example.com")?;
|
||||
/// use matrix_sdk::{
|
||||
/// ruma::{
|
||||
/// api::client::r0::directory::get_public_rooms_filtered::Request,
|
||||
/// api::client::directory::get_public_rooms_filtered::v3::Request,
|
||||
/// directory::Filter,
|
||||
/// assign,
|
||||
/// }
|
||||
@@ -1475,8 +1484,8 @@ impl Client {
|
||||
/// ```
|
||||
pub async fn public_rooms_filtered(
|
||||
&self,
|
||||
room_search: impl Into<get_public_rooms_filtered::Request<'_>>,
|
||||
) -> HttpResult<get_public_rooms_filtered::Response> {
|
||||
room_search: impl Into<get_public_rooms_filtered::v3::Request<'_>>,
|
||||
) -> HttpResult<get_public_rooms_filtered::v3::Response> {
|
||||
let request = room_search.into();
|
||||
self.send(request, None).await
|
||||
}
|
||||
@@ -1516,7 +1525,7 @@ impl Client {
|
||||
&self,
|
||||
content_type: &Mime,
|
||||
reader: &mut (impl Read + ?Sized),
|
||||
) -> Result<create_content::Response> {
|
||||
) -> Result<create_content::v3::Response> {
|
||||
let mut data = Vec::new();
|
||||
reader.read_to_end(&mut data)?;
|
||||
|
||||
@@ -1525,7 +1534,7 @@ impl Client {
|
||||
MIN_UPLOAD_REQUEST_TIMEOUT,
|
||||
);
|
||||
|
||||
let request = assign!(create_content::Request::new(&data), {
|
||||
let request = assign!(create_content::v3::Request::new(&data), {
|
||||
content_type: Some(content_type.essence_str()),
|
||||
});
|
||||
|
||||
@@ -1558,13 +1567,13 @@ impl Client {
|
||||
/// # block_on(async {
|
||||
/// # let homeserver = Url::parse("http://localhost:8080")?;
|
||||
/// # let mut client = Client::new(homeserver).await?;
|
||||
/// use matrix_sdk::ruma::{api::client::r0::profile, user_id};
|
||||
/// use matrix_sdk::ruma::{api::client::profile, user_id};
|
||||
///
|
||||
/// // First construct the request you want to make
|
||||
/// // See https://docs.rs/ruma-client-api/latest/ruma_client_api/index.html
|
||||
/// // for all available Endpoints
|
||||
/// let user_id = user_id!("@example:localhost");
|
||||
/// let request = profile::get_profile::Request::new(&user_id);
|
||||
/// let request = profile::get_profile::v3::Request::new(&user_id);
|
||||
///
|
||||
/// // Start the request using Client::send()
|
||||
/// let response = client.send(request, None).await?;
|
||||
@@ -1608,8 +1617,8 @@ impl Client {
|
||||
/// }
|
||||
/// # Result::<_, matrix_sdk::Error>::Ok(()) });
|
||||
/// ```
|
||||
pub async fn devices(&self) -> HttpResult<get_devices::Response> {
|
||||
let request = get_devices::Request::new();
|
||||
pub async fn devices(&self) -> HttpResult<get_devices::v3::Response> {
|
||||
let request = get_devices::v3::Request::new();
|
||||
|
||||
self.send(request, None).await
|
||||
}
|
||||
@@ -1631,7 +1640,7 @@ impl Client {
|
||||
/// # use matrix_sdk::{
|
||||
/// # ruma::{
|
||||
/// # api::{
|
||||
/// # client::r0::uiaa,
|
||||
/// # client::uiaa,
|
||||
/// # error::{FromHttpResponseError, ServerError},
|
||||
/// # },
|
||||
/// # assign, device_id,
|
||||
@@ -1650,8 +1659,12 @@ impl Client {
|
||||
/// if let Err(e) = client.delete_devices(devices, None).await {
|
||||
/// if let Some(info) = e.uiaa_response() {
|
||||
/// let auth_data = uiaa::AuthData::Password(assign!(
|
||||
/// uiaa::Password::new(uiaa::UserIdentifier::MatrixId("example"), "wordpass"),
|
||||
/// { session: info.session.as_deref() }
|
||||
/// uiaa::Password::new(
|
||||
/// uiaa::UserIdentifier::UserIdOrLocalpart("example"),
|
||||
/// "wordpass",
|
||||
/// ), {
|
||||
/// session: info.session.as_deref(),
|
||||
/// }
|
||||
/// ));
|
||||
///
|
||||
/// client
|
||||
@@ -1664,8 +1677,8 @@ impl Client {
|
||||
&self,
|
||||
devices: &[Box<DeviceId>],
|
||||
auth_data: Option<AuthData<'_>>,
|
||||
) -> HttpResult<delete_devices::Response> {
|
||||
let mut request = delete_devices::Request::new(devices);
|
||||
) -> HttpResult<delete_devices::v3::Response> {
|
||||
let mut request = delete_devices::v3::Request::new(devices);
|
||||
request.auth = auth_data;
|
||||
|
||||
self.send(request, None).await
|
||||
@@ -1757,7 +1770,7 @@ impl Client {
|
||||
/// [`timeout`]: crate::config::SyncSettings#method.timeout
|
||||
/// [`full_state`]: crate::config::SyncSettings#method.full_state
|
||||
/// [`filter`]: crate::config::SyncSettings#method.filter
|
||||
/// [`Filter`]: ruma::api::client::r0::sync::sync_events::Filter
|
||||
/// [`Filter`]: ruma::api::client::sync::sync_events::v3::Filter
|
||||
/// [`next_batch`]: SyncResponse#structfield.next_batch
|
||||
/// [`get_or_upload_filter()`]: #method.get_or_upload_filter
|
||||
/// [long polling]: #long-polling
|
||||
@@ -1778,7 +1791,7 @@ impl Client {
|
||||
error!(error =? e, "Error while sending outgoing E2EE requests");
|
||||
};
|
||||
|
||||
let request = assign!(sync_events::Request::new(), {
|
||||
let request = assign!(sync_events::v3::Request::new(), {
|
||||
filter: sync_settings.filter.as_ref(),
|
||||
since: sync_settings.token.as_deref(),
|
||||
full_state: sync_settings.full_state,
|
||||
@@ -2034,7 +2047,7 @@ impl Client {
|
||||
let content: Vec<u8> = match &request.media_type {
|
||||
MediaType::Encrypted(file) => {
|
||||
let content: Vec<u8> =
|
||||
self.send(get_content::Request::from_url(&file.url)?, None).await?.file;
|
||||
self.send(get_content::v3::Request::from_url(&file.url)?, None).await?.file;
|
||||
|
||||
#[cfg(feature = "encryption")]
|
||||
let content = {
|
||||
@@ -2055,13 +2068,17 @@ impl Client {
|
||||
MediaType::Uri(uri) => {
|
||||
if let MediaFormat::Thumbnail(size) = &request.format {
|
||||
self.send(
|
||||
get_content_thumbnail::Request::from_url(uri, size.width, size.height)?,
|
||||
get_content_thumbnail::v3::Request::from_url(
|
||||
uri,
|
||||
size.width,
|
||||
size.height,
|
||||
)?,
|
||||
None,
|
||||
)
|
||||
.await?
|
||||
.file
|
||||
} else {
|
||||
self.send(get_content::Request::from_url(uri)?, None).await?.file
|
||||
self.send(get_content::v3::Request::from_url(uri)?, None).await?.file
|
||||
}
|
||||
}
|
||||
};
|
||||
@@ -2208,8 +2225,8 @@ impl Client {
|
||||
}
|
||||
|
||||
/// Gets information about the owner of a given access token.
|
||||
pub async fn whoami(&self) -> HttpResult<whoami::Response> {
|
||||
let request = whoami::Request::new();
|
||||
pub async fn whoami(&self) -> HttpResult<whoami::v3::Response> {
|
||||
let request = whoami::v3::Request::new();
|
||||
self.send(request, None).await
|
||||
}
|
||||
|
||||
@@ -2322,17 +2339,15 @@ pub(crate) mod test {
|
||||
api::{
|
||||
client::{
|
||||
self as client_api,
|
||||
r0::{
|
||||
account::register::{RegistrationKind, Request as RegistrationRequest},
|
||||
directory::{
|
||||
get_public_rooms,
|
||||
get_public_rooms_filtered::{self, Request as PublicRoomsFilterRequest},
|
||||
},
|
||||
media::get_content_thumbnail::Method,
|
||||
membership::Invite3pidInit,
|
||||
session::get_login_types::LoginType,
|
||||
uiaa::{self, UiaaResponse},
|
||||
account::register::{v3::Request as RegistrationRequest, RegistrationKind},
|
||||
directory::{
|
||||
get_public_rooms,
|
||||
get_public_rooms_filtered::{self, v3::Request as PublicRoomsFilterRequest},
|
||||
},
|
||||
media::get_content_thumbnail::v3::Method,
|
||||
membership::Invite3pidInit,
|
||||
session::get_login_types::v3::LoginType,
|
||||
uiaa::{self, UiaaResponse},
|
||||
},
|
||||
error::{FromHttpResponseError, ServerError},
|
||||
},
|
||||
@@ -2512,7 +2527,7 @@ pub(crate) mod test {
|
||||
|
||||
let homeserver = Url::from_str(&mockito::server_url()).unwrap();
|
||||
let client = Client::new(homeserver).await.unwrap();
|
||||
let idp = crate::client::get_login_types::IdentityProvider::new(
|
||||
let idp = crate::client::get_login_types::v3::IdentityProvider::new(
|
||||
"some-id".to_string(),
|
||||
"idp-name".to_string(),
|
||||
);
|
||||
@@ -2861,7 +2876,7 @@ pub(crate) mod test {
|
||||
.with_body(test_json::PUBLIC_ROOMS.to_string())
|
||||
.create();
|
||||
|
||||
let get_public_rooms::Response { chunk, .. } =
|
||||
let get_public_rooms::v3::Response { chunk, .. } =
|
||||
client.public_rooms(Some(10), None, None).await.unwrap();
|
||||
assert_eq!(chunk.len(), 1);
|
||||
}
|
||||
@@ -2880,7 +2895,7 @@ pub(crate) mod test {
|
||||
let filter = assign!(Filter::new(), { generic_search_term });
|
||||
let request = assign!(PublicRoomsFilterRequest::new(), { filter });
|
||||
|
||||
let get_public_rooms_filtered::Response { chunk, .. } =
|
||||
let get_public_rooms_filtered::v3::Response { chunk, .. } =
|
||||
client.public_rooms_filtered(request).await.unwrap();
|
||||
assert_eq!(chunk.len(), 1);
|
||||
}
|
||||
@@ -3581,7 +3596,10 @@ pub(crate) mod test {
|
||||
auth_parameters.insert("password".to_owned(), "wordpass".into());
|
||||
|
||||
let auth_data = uiaa::AuthData::Password(assign!(
|
||||
uiaa::Password::new(uiaa::UserIdentifier::MatrixId("example"), "wordpass"),
|
||||
uiaa::Password::new(
|
||||
uiaa::UserIdentifier::UserIdOrLocalpart("example"),
|
||||
"wordpass",
|
||||
),
|
||||
{ session: info.session.as_deref() }
|
||||
));
|
||||
|
||||
|
||||
@@ -14,14 +14,14 @@
|
||||
|
||||
use std::time::Duration;
|
||||
|
||||
use ruma::api::client::r0::sync::sync_events;
|
||||
use ruma::api::client::sync::sync_events;
|
||||
|
||||
const DEFAULT_SYNC_TIMEOUT: Duration = Duration::from_secs(30);
|
||||
|
||||
#[derive(Debug, Clone)]
|
||||
/// Settings for a sync call.
|
||||
pub struct SyncSettings<'a> {
|
||||
pub(crate) filter: Option<sync_events::Filter<'a>>,
|
||||
pub(crate) filter: Option<sync_events::v3::Filter<'a>>,
|
||||
pub(crate) timeout: Option<Duration>,
|
||||
pub(crate) token: Option<String>,
|
||||
pub(crate) full_state: bool,
|
||||
@@ -76,7 +76,7 @@ impl<'a> SyncSettings<'a> {
|
||||
/// * `filter` - The filter configuration that should be used for the sync
|
||||
/// call.
|
||||
#[must_use]
|
||||
pub fn filter(mut self, filter: sync_events::Filter<'a>) -> Self {
|
||||
pub fn filter(mut self, filter: sync_events::v3::Filter<'a>) -> Self {
|
||||
self.filter = Some(filter);
|
||||
self
|
||||
}
|
||||
|
||||
@@ -266,11 +266,11 @@ use matrix_sdk_base::{
|
||||
};
|
||||
use matrix_sdk_common::instant::Duration;
|
||||
use ruma::{
|
||||
api::client::r0::{
|
||||
backup::add_backup_keys::Response as KeysBackupResponse,
|
||||
keys::{get_keys, upload_keys, upload_signing_keys::Request as UploadSigningKeysRequest},
|
||||
api::client::{
|
||||
backup::add_backup_keys::v3::Response as KeysBackupResponse,
|
||||
keys::{get_keys, upload_keys, upload_signing_keys::v3::Request as UploadSigningKeysRequest},
|
||||
message::send_message_event,
|
||||
to_device::send_event_to_device::{
|
||||
to_device::send_event_to_device::v3::{
|
||||
Request as RumaToDeviceRequest, Response as ToDeviceResponse,
|
||||
},
|
||||
uiaa::AuthData,
|
||||
@@ -500,7 +500,7 @@ impl Client {
|
||||
/// ```no_run
|
||||
/// # use std::{convert::TryFrom, collections::BTreeMap};
|
||||
/// # use matrix_sdk::{
|
||||
/// # ruma::{api::client::r0::uiaa, assign},
|
||||
/// # ruma::{api::client::uiaa, assign},
|
||||
/// # Client,
|
||||
/// # };
|
||||
/// # use url::Url;
|
||||
@@ -512,8 +512,12 @@ impl Client {
|
||||
/// if let Err(e) = client.bootstrap_cross_signing(None).await {
|
||||
/// if let Some(response) = e.uiaa_response() {
|
||||
/// let auth_data = uiaa::AuthData::Password(assign!(
|
||||
/// uiaa::Password::new(uiaa::UserIdentifier::MatrixId("example"), "wordpass"),
|
||||
/// { session: response.session.as_deref() }
|
||||
/// uiaa::Password::new(
|
||||
/// uiaa::UserIdentifier::UserIdOrLocalpart("example"),
|
||||
/// "wordpass",
|
||||
/// ), {
|
||||
/// session: response.session.as_deref(),
|
||||
/// }
|
||||
/// ));
|
||||
///
|
||||
/// client
|
||||
@@ -720,8 +724,8 @@ impl Client {
|
||||
&self,
|
||||
request_id: &TransactionId,
|
||||
device_keys: BTreeMap<Box<UserId>, Vec<Box<DeviceId>>>,
|
||||
) -> Result<get_keys::Response> {
|
||||
let request = assign!(get_keys::Request::new(), { device_keys });
|
||||
) -> Result<get_keys::v3::Response> {
|
||||
let request = assign!(get_keys::v3::Request::new(), { device_keys });
|
||||
|
||||
let response = self.send(request, None).await?;
|
||||
self.mark_request_as_sent(request_id, &response).await?;
|
||||
@@ -852,12 +856,12 @@ impl Client {
|
||||
async fn send_account_data(
|
||||
&self,
|
||||
content: ruma::events::AnyGlobalAccountDataEventContent,
|
||||
) -> Result<ruma::api::client::r0::config::set_global_account_data::Response> {
|
||||
) -> Result<ruma::api::client::config::set_global_account_data::v3::Response> {
|
||||
let own_user =
|
||||
self.user_id().await.ok_or_else(|| Error::from(HttpError::AuthenticationRequired))?;
|
||||
let data = serde_json::value::to_raw_value(&content)?;
|
||||
|
||||
let request = ruma::api::client::r0::config::set_global_account_data::Request::new(
|
||||
let request = ruma::api::client::config::set_global_account_data::v3::Request::new(
|
||||
&data,
|
||||
ruma::events::EventContent::event_type(&content),
|
||||
&own_user,
|
||||
@@ -869,7 +873,7 @@ impl Client {
|
||||
#[cfg(feature = "encryption")]
|
||||
pub(crate) async fn create_dm_room(&self, user_id: Box<UserId>) -> Result<Option<room::Joined>> {
|
||||
use ruma::{
|
||||
api::client::r0::room::create_room::RoomPreset,
|
||||
api::client::room::create_room::v3::RoomPreset,
|
||||
events::AnyGlobalAccountDataEventContent,
|
||||
};
|
||||
|
||||
@@ -880,7 +884,7 @@ impl Client {
|
||||
let invite = &[user_id.clone()];
|
||||
|
||||
let request = assign!(
|
||||
ruma::api::client::r0::room::create_room::Request::new(),
|
||||
ruma::api::client::room::create_room::v3::Request::new(),
|
||||
{
|
||||
invite,
|
||||
is_direct: true,
|
||||
@@ -960,8 +964,8 @@ impl Client {
|
||||
pub(crate) async fn keys_upload(
|
||||
&self,
|
||||
request_id: &TransactionId,
|
||||
request: &upload_keys::Request,
|
||||
) -> Result<upload_keys::Response> {
|
||||
request: &upload_keys::v3::Request,
|
||||
) -> Result<upload_keys::v3::Response> {
|
||||
debug!(
|
||||
device_keys = request.device_keys.is_some(),
|
||||
one_time_key_count = request.one_time_keys.len(),
|
||||
@@ -978,7 +982,7 @@ impl Client {
|
||||
pub(crate) async fn room_send_helper(
|
||||
&self,
|
||||
request: &RoomMessageRequest,
|
||||
) -> Result<send_message_event::Response> {
|
||||
) -> Result<send_message_event::v3::Response> {
|
||||
let content = request.content.clone();
|
||||
let txn_id = &request.txn_id;
|
||||
let room_id = &request.room_id;
|
||||
@@ -1072,7 +1076,7 @@ impl Client {
|
||||
&self,
|
||||
request: &matrix_sdk_base::crypto::KeysBackupRequest,
|
||||
) -> Result<KeysBackupResponse> {
|
||||
let request = ruma::api::client::r0::backup::add_backup_keys::Request::new(
|
||||
let request = ruma::api::client::backup::add_backup_keys::v3::Request::new(
|
||||
&request.version,
|
||||
request.rooms.to_owned(),
|
||||
);
|
||||
|
||||
@@ -28,7 +28,7 @@ use reqwest::Error as ReqwestError;
|
||||
use ruma::{
|
||||
api::{
|
||||
client::{
|
||||
r0::uiaa::{UiaaInfo, UiaaResponse as UiaaError},
|
||||
uiaa::{UiaaInfo, UiaaResponse as UiaaError},
|
||||
Error as RumaClientApiError,
|
||||
},
|
||||
error::{FromHttpResponseError, IntoHttpError, MatrixError as RumaApiError, ServerError},
|
||||
|
||||
@@ -19,8 +19,8 @@ use http::Response as HttpResponse;
|
||||
use matrix_sdk_common::{async_trait, locks::RwLock, AsyncTraitDeps};
|
||||
use reqwest::{Client, Response};
|
||||
use ruma::api::{
|
||||
client::r0::media::create_content, error::FromHttpResponseError, AuthScheme, IncomingResponse,
|
||||
OutgoingRequest, OutgoingRequestAppserviceExt, SendAccessToken,
|
||||
client::media::create_content, error::FromHttpResponseError, AuthScheme, IncomingResponse,
|
||||
MatrixVersion, OutgoingRequest, OutgoingRequestAppserviceExt, SendAccessToken,
|
||||
};
|
||||
use tracing::trace;
|
||||
use url::Url;
|
||||
@@ -164,6 +164,8 @@ impl HttpClient {
|
||||
.try_into_http_request::<BytesMut>(
|
||||
&self.homeserver.read().await.to_string(),
|
||||
access_token,
|
||||
// FIXME: Use versions reported by server
|
||||
&[MatrixVersion::V1_0],
|
||||
)?
|
||||
.map(|body| body.freeze());
|
||||
|
||||
@@ -194,6 +196,8 @@ impl HttpClient {
|
||||
&self.homeserver.read().await.to_string(),
|
||||
access_token,
|
||||
&user_id,
|
||||
// FIXME: Use versions reported by server
|
||||
&[MatrixVersion::V1_0],
|
||||
)?
|
||||
.map(|body| body.freeze());
|
||||
|
||||
@@ -202,11 +206,11 @@ impl HttpClient {
|
||||
|
||||
pub async fn upload(
|
||||
&self,
|
||||
request: create_content::Request<'_>,
|
||||
request: create_content::v3::Request<'_>,
|
||||
config: Option<RequestConfig>,
|
||||
) -> Result<create_content::Response, HttpError> {
|
||||
) -> Result<create_content::v3::Response, HttpError> {
|
||||
let response = self.send_request(request, self.session.clone(), config).await?;
|
||||
Ok(create_content::Response::try_from_http_response(response)?)
|
||||
Ok(create_content::v3::Response::try_from_http_response(response)?)
|
||||
}
|
||||
|
||||
pub async fn send<Request>(
|
||||
|
||||
@@ -7,10 +7,10 @@ use matrix_sdk_base::{
|
||||
};
|
||||
use matrix_sdk_common::locks::Mutex;
|
||||
use ruma::{
|
||||
api::client::r0::{
|
||||
api::client::{
|
||||
filter::{LazyLoadOptions, RoomEventFilter},
|
||||
membership::{get_member_events, join_room_by_id, leave_room},
|
||||
message::get_message_events::{self, Direction},
|
||||
message::get_message_events::{self, v3::Direction},
|
||||
room::get_room_event,
|
||||
tag::{create_tag, delete_tag},
|
||||
},
|
||||
@@ -81,7 +81,7 @@ impl Common {
|
||||
///
|
||||
/// Only invited and joined rooms can be left
|
||||
pub(crate) async fn leave(&self) -> Result<()> {
|
||||
let request = leave_room::Request::new(self.inner.room_id());
|
||||
let request = leave_room::v3::Request::new(self.inner.room_id());
|
||||
let _response = self.client.send(request, None).await?;
|
||||
|
||||
Ok(())
|
||||
@@ -91,7 +91,7 @@ impl Common {
|
||||
///
|
||||
/// Only invited and left rooms can be joined via this method
|
||||
pub(crate) async fn join(&self) -> Result<()> {
|
||||
let request = join_room_by_id::Request::new(self.inner.room_id());
|
||||
let request = join_room_by_id::v3::Request::new(self.inner.room_id());
|
||||
let _response = self.client.send(request, None).await?;
|
||||
|
||||
Ok(())
|
||||
@@ -150,7 +150,7 @@ impl Common {
|
||||
/// # use std::convert::TryFrom;
|
||||
/// use matrix_sdk::{room::MessagesOptions, Client};
|
||||
/// # use matrix_sdk::ruma::{
|
||||
/// # api::client::r0::filter::RoomEventFilter,
|
||||
/// # api::client::filter::RoomEventFilter,
|
||||
/// # room_id,
|
||||
/// # };
|
||||
/// # use url::Url;
|
||||
@@ -220,7 +220,7 @@ impl Common {
|
||||
/// # use std::convert::TryFrom;
|
||||
/// use matrix_sdk::{room::MessagesOptions, Client};
|
||||
/// # use matrix_sdk::ruma::{
|
||||
/// # api::client::r0::filter::RoomEventFilter,
|
||||
/// # api::client::filter::RoomEventFilter,
|
||||
/// # room_id,
|
||||
/// # };
|
||||
/// # use url::Url;
|
||||
@@ -299,7 +299,7 @@ impl Common {
|
||||
/// # use std::convert::TryFrom;
|
||||
/// use matrix_sdk::{room::MessagesOptions, Client};
|
||||
/// # use matrix_sdk::ruma::{
|
||||
/// # api::client::r0::filter::RoomEventFilter,
|
||||
/// # api::client::filter::RoomEventFilter,
|
||||
/// # room_id,
|
||||
/// # };
|
||||
/// # use url::Url;
|
||||
@@ -358,7 +358,7 @@ impl Common {
|
||||
/// # use std::convert::TryFrom;
|
||||
/// use matrix_sdk::{room::MessagesOptions, Client};
|
||||
/// # use matrix_sdk::ruma::{
|
||||
/// # api::client::r0::filter::RoomEventFilter,
|
||||
/// # api::client::filter::RoomEventFilter,
|
||||
/// # room_id,
|
||||
/// # };
|
||||
/// # use url::Url;
|
||||
@@ -434,7 +434,7 @@ impl Common {
|
||||
|
||||
/// Fetch the event with the given `EventId` in this room.
|
||||
pub async fn event(&self, event_id: &EventId) -> Result<RoomEvent> {
|
||||
let request = get_room_event::Request::new(self.room_id(), event_id);
|
||||
let request = get_room_event::v3::Request::new(self.room_id(), event_id);
|
||||
let event = self.client.send(request, None).await?.event;
|
||||
|
||||
#[cfg(feature = "encryption")]
|
||||
@@ -460,7 +460,7 @@ impl Common {
|
||||
|
||||
let _guard = mutex.lock().await;
|
||||
|
||||
let request = get_member_events::Request::new(self.inner.room_id());
|
||||
let request = get_member_events::v3::Request::new(self.inner.room_id());
|
||||
let response = self.client.send(request, None).await?;
|
||||
|
||||
let response =
|
||||
@@ -680,7 +680,7 @@ impl Common {
|
||||
|
||||
/// Adds a tag to the room, or updates it if it already exists.
|
||||
///
|
||||
/// Returns the [`create_tag::Response`] from the server.
|
||||
/// Returns the [`create_tag::v3::Response`] from the server.
|
||||
///
|
||||
/// # Arguments
|
||||
/// * `tag` - The tag to add or update.
|
||||
@@ -712,22 +712,22 @@ impl Common {
|
||||
&self,
|
||||
tag: TagName,
|
||||
tag_info: TagInfo,
|
||||
) -> HttpResult<create_tag::Response> {
|
||||
) -> HttpResult<create_tag::v3::Response> {
|
||||
let user_id = self.client.user_id().await.ok_or(HttpError::AuthenticationRequired)?;
|
||||
let request =
|
||||
create_tag::Request::new(&user_id, self.inner.room_id(), tag.as_ref(), tag_info);
|
||||
create_tag::v3::Request::new(&user_id, self.inner.room_id(), tag.as_ref(), tag_info);
|
||||
self.client.send(request, None).await
|
||||
}
|
||||
|
||||
/// Removes a tag from the room.
|
||||
///
|
||||
/// Returns the [`delete_tag::Response`] from the server.
|
||||
/// Returns the [`delete_tag::v3::Response`] from the server.
|
||||
///
|
||||
/// # Arguments
|
||||
/// * `tag` - The tag to remove.
|
||||
pub async fn remove_tag(&self, tag: TagName) -> HttpResult<delete_tag::Response> {
|
||||
pub async fn remove_tag(&self, tag: TagName) -> HttpResult<delete_tag::v3::Response> {
|
||||
let user_id = self.client.user_id().await.ok_or(HttpError::AuthenticationRequired)?;
|
||||
let request = delete_tag::Request::new(&user_id, self.inner.room_id(), tag.as_ref());
|
||||
let request = delete_tag::v3::Request::new(&user_id, self.inner.room_id(), tag.as_ref());
|
||||
self.client.send(request, None).await
|
||||
}
|
||||
}
|
||||
@@ -784,8 +784,8 @@ impl<'a> MessagesOptions<'a> {
|
||||
Self::new(from, Direction::Forward)
|
||||
}
|
||||
|
||||
fn into_request(self, room_id: &'a RoomId) -> get_message_events::Request {
|
||||
assign!(get_message_events::Request::new(room_id, self.from, self.dir), {
|
||||
fn into_request(self, room_id: &'a RoomId) -> get_message_events::v3::Request {
|
||||
assign!(get_message_events::v3::Request::new(room_id, self.from, self.dir), {
|
||||
to: self.to,
|
||||
limit: self.limit,
|
||||
filter: self.filter,
|
||||
|
||||
@@ -12,10 +12,10 @@ use matrix_sdk_common::instant::{Duration, Instant};
|
||||
use matrix_sdk_common::locks::Mutex;
|
||||
use mime::{self, Mime};
|
||||
use ruma::{
|
||||
api::client::r0::{
|
||||
api::client::{
|
||||
membership::{
|
||||
ban_user,
|
||||
invite_user::{self, InvitationRecipient},
|
||||
invite_user::{self, v3::InvitationRecipient},
|
||||
kick_user, Invite3pid,
|
||||
},
|
||||
message::send_message_event,
|
||||
@@ -23,7 +23,7 @@ use ruma::{
|
||||
receipt::create_receipt,
|
||||
redact::redact_event,
|
||||
state::send_state_event,
|
||||
typing::create_typing_event::{Request as TypingRequest, Typing},
|
||||
typing::create_typing_event::v3::{Request as TypingRequest, Typing},
|
||||
},
|
||||
assign,
|
||||
events::{room::message::RoomMessageEventContent, MessageEventContent, StateEventContent},
|
||||
@@ -96,7 +96,8 @@ impl Joined {
|
||||
///
|
||||
/// * `reason` - The reason for banning this user.
|
||||
pub async fn ban_user(&self, user_id: &UserId, reason: Option<&str>) -> Result<()> {
|
||||
let request = assign!(ban_user::Request::new(self.inner.room_id(), user_id), { reason });
|
||||
let request =
|
||||
assign!(ban_user::v3::Request::new(self.inner.room_id(), user_id), { reason });
|
||||
self.client.send(request, None).await?;
|
||||
Ok(())
|
||||
}
|
||||
@@ -110,7 +111,8 @@ impl Joined {
|
||||
///
|
||||
/// * `reason` - Optional reason why the room member is being kicked out.
|
||||
pub async fn kick_user(&self, user_id: &UserId, reason: Option<&str>) -> Result<()> {
|
||||
let request = assign!(kick_user::Request::new(self.inner.room_id(), user_id), { reason });
|
||||
let request =
|
||||
assign!(kick_user::v3::Request::new(self.inner.room_id(), user_id), { reason });
|
||||
self.client.send(request, None).await?;
|
||||
Ok(())
|
||||
}
|
||||
@@ -123,7 +125,7 @@ impl Joined {
|
||||
pub async fn invite_user_by_id(&self, user_id: &UserId) -> Result<()> {
|
||||
let recipient = InvitationRecipient::UserId { user_id };
|
||||
|
||||
let request = invite_user::Request::new(self.inner.room_id(), recipient);
|
||||
let request = invite_user::v3::Request::new(self.inner.room_id(), recipient);
|
||||
self.client.send(request, None).await?;
|
||||
|
||||
Ok(())
|
||||
@@ -136,7 +138,7 @@ impl Joined {
|
||||
/// * `invite_id` - A third party id of a user to invite to the room.
|
||||
pub async fn invite_user_by_3pid(&self, invite_id: Invite3pid<'_>) -> Result<()> {
|
||||
let recipient = InvitationRecipient::ThirdPartyId(invite_id);
|
||||
let request = invite_user::Request::new(self.inner.room_id(), recipient);
|
||||
let request = invite_user::v3::Request::new(self.inner.room_id(), recipient);
|
||||
self.client.send(request, None).await?;
|
||||
|
||||
Ok(())
|
||||
@@ -158,7 +160,7 @@ impl Joined {
|
||||
///
|
||||
/// ```no_run
|
||||
/// use std::time::Duration;
|
||||
/// use matrix_sdk::ruma::api::client::r0::typing::create_typing_event::Typing;
|
||||
/// use matrix_sdk::ruma::api::client::typing::create_typing_event::v3::Typing;
|
||||
///
|
||||
/// # use matrix_sdk::{
|
||||
/// # Client, config::SyncSettings,
|
||||
@@ -228,7 +230,7 @@ impl Joined {
|
||||
/// on.
|
||||
pub async fn read_receipt(&self, event_id: &EventId) -> Result<()> {
|
||||
let request =
|
||||
create_receipt::Request::new(self.inner.room_id(), ReceiptType::Read, event_id);
|
||||
create_receipt::v3::Request::new(self.inner.room_id(), ReceiptType::Read, event_id);
|
||||
|
||||
self.client.send(request, None).await?;
|
||||
Ok(())
|
||||
@@ -248,9 +250,10 @@ impl Joined {
|
||||
fully_read: &EventId,
|
||||
read_receipt: Option<&EventId>,
|
||||
) -> Result<()> {
|
||||
let request = assign!(set_read_marker::Request::new(self.inner.room_id(), fully_read), {
|
||||
read_receipt
|
||||
});
|
||||
let request =
|
||||
assign!(set_read_marker::v3::Request::new(self.inner.room_id(), fully_read), {
|
||||
read_receipt
|
||||
});
|
||||
|
||||
self.client.send(request, None).await?;
|
||||
Ok(())
|
||||
@@ -465,7 +468,7 @@ impl Joined {
|
||||
&self,
|
||||
content: impl MessageEventContent,
|
||||
txn_id: Option<&TransactionId>,
|
||||
) -> Result<send_message_event::Response> {
|
||||
) -> Result<send_message_event::v3::Response> {
|
||||
let event_type = content.event_type();
|
||||
let content = serde_json::to_value(&content)?;
|
||||
|
||||
@@ -534,7 +537,7 @@ impl Joined {
|
||||
content: Value,
|
||||
event_type: &str,
|
||||
txn_id: Option<&TransactionId>,
|
||||
) -> Result<send_message_event::Response> {
|
||||
) -> Result<send_message_event::v3::Response> {
|
||||
let txn_id: Box<TransactionId> = txn_id.map_or_else(TransactionId::new, ToOwned::to_owned);
|
||||
|
||||
#[cfg(not(feature = "encryption"))]
|
||||
@@ -577,7 +580,7 @@ impl Joined {
|
||||
(serde_json::value::to_raw_value(&content)?, event_type)
|
||||
};
|
||||
|
||||
let request = send_message_event::Request::new_raw(
|
||||
let request = send_message_event::v3::Request::new_raw(
|
||||
self.inner.room_id(),
|
||||
&txn_id,
|
||||
event_type,
|
||||
@@ -642,7 +645,7 @@ impl Joined {
|
||||
content_type: &Mime,
|
||||
reader: &mut R,
|
||||
config: AttachmentConfig<'_, T>,
|
||||
) -> Result<send_message_event::Response> {
|
||||
) -> Result<send_message_event::v3::Response> {
|
||||
let reader = &mut BufReader::new(reader);
|
||||
|
||||
#[cfg(feature = "image_proc")]
|
||||
@@ -721,7 +724,7 @@ impl Joined {
|
||||
content_type: &Mime,
|
||||
reader: &mut R,
|
||||
config: AttachmentConfig<'_, T>,
|
||||
) -> Result<send_message_event::Response> {
|
||||
) -> Result<send_message_event::v3::Response> {
|
||||
#[cfg(feature = "encryption")]
|
||||
let content = if self.is_encrypted() {
|
||||
self.client
|
||||
@@ -805,8 +808,9 @@ impl Joined {
|
||||
&self,
|
||||
content: impl StateEventContent,
|
||||
state_key: &str,
|
||||
) -> Result<send_state_event::Response> {
|
||||
let request = send_state_event::Request::new(self.inner.room_id(), state_key, &content)?;
|
||||
) -> Result<send_state_event::v3::Response> {
|
||||
let request =
|
||||
send_state_event::v3::Request::new(self.inner.room_id(), state_key, &content)?;
|
||||
let response = self.client.send(request, None).await?;
|
||||
Ok(response)
|
||||
}
|
||||
@@ -849,9 +853,9 @@ impl Joined {
|
||||
content: Value,
|
||||
event_type: &str,
|
||||
state_key: &str,
|
||||
) -> Result<send_state_event::Response> {
|
||||
) -> Result<send_state_event::v3::Response> {
|
||||
let content = Raw::from_json(serde_json::value::to_raw_value(&content)?);
|
||||
let request = send_state_event::Request::new_raw(
|
||||
let request = send_state_event::v3::Request::new_raw(
|
||||
self.inner.room_id(),
|
||||
event_type,
|
||||
state_key,
|
||||
@@ -863,7 +867,7 @@ impl Joined {
|
||||
|
||||
/// Strips all information out of an event of the room.
|
||||
///
|
||||
/// Returns the [`redact_event::Response`] from the server.
|
||||
/// Returns the [`redact_event::v3::Response`] from the server.
|
||||
///
|
||||
/// This cannot be undone. Users may redact their own events, and any user
|
||||
/// with a power level greater than or equal to the redact power level of
|
||||
@@ -899,10 +903,10 @@ impl Joined {
|
||||
event_id: &EventId,
|
||||
reason: Option<&str>,
|
||||
txn_id: Option<Box<TransactionId>>,
|
||||
) -> HttpResult<redact_event::Response> {
|
||||
) -> HttpResult<redact_event::v3::Response> {
|
||||
let txn_id = txn_id.unwrap_or_else(TransactionId::new);
|
||||
let request =
|
||||
assign!(redact_event::Request::new(self.inner.room_id(), event_id, &txn_id), {
|
||||
assign!(redact_event::v3::Request::new(self.inner.room_id(), event_id, &txn_id), {
|
||||
reason
|
||||
});
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
use std::ops::Deref;
|
||||
|
||||
use ruma::api::client::r0::membership::forget_room;
|
||||
use ruma::api::client::membership::forget_room;
|
||||
|
||||
use crate::{room::Common, BaseRoom, Client, Result, RoomType};
|
||||
|
||||
@@ -40,7 +40,7 @@ impl Left {
|
||||
///
|
||||
/// This communicates to the homeserver that it should forget the room.
|
||||
pub async fn forget(&self) -> Result<()> {
|
||||
let request = forget_room::Request::new(self.inner.room_id());
|
||||
let request = forget_room::v3::Request::new(self.inner.room_id());
|
||||
let _response = self.client.send(request, None).await?;
|
||||
self.client.store().remove_room(self.inner.room_id()).await?;
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@ use matrix_sdk_base::{
|
||||
deserialized_responses::{JoinedRoom, LeftRoom, SyncResponse},
|
||||
instant::Instant,
|
||||
};
|
||||
use ruma::api::client::r0::sync::sync_events;
|
||||
use ruma::api::client::sync::sync_events;
|
||||
use tracing::{error, warn};
|
||||
|
||||
use crate::{event_handler::EventKind, Client, Result};
|
||||
@@ -15,7 +15,7 @@ use crate::{event_handler::EventKind, Client, Result};
|
||||
impl Client {
|
||||
pub(crate) async fn process_sync(
|
||||
&self,
|
||||
response: sync_events::Response,
|
||||
response: sync_events::v3::Response,
|
||||
) -> Result<SyncResponse> {
|
||||
let response = self.base_client().receive_sync_response(response).await?;
|
||||
let SyncResponse {
|
||||
|
||||
Reference in New Issue
Block a user