refactor: Use owned_*_id! macros rather than *_id!().to_owned()
Signed-off-by: Kévin Commaille <zecakeh@tedomum.fr>
This commit is contained in:
committed by
Ivan Enderlin
parent
9870228a76
commit
5d18820120
@@ -15,11 +15,9 @@ use matrix_sdk_ui::timeline::{TimelineBuilder, TimelineFocus};
|
||||
use ruma::{
|
||||
EventId, MilliSecondsSinceUnixEpoch, OwnedEventId, OwnedUserId,
|
||||
api::client::membership::get_member_events,
|
||||
device_id,
|
||||
events::room::member::{MembershipState, RoomMemberEvent},
|
||||
mxc_uri, owned_room_id, owned_user_id,
|
||||
mxc_uri, owned_device_id, owned_room_id, owned_user_id,
|
||||
serde::Raw,
|
||||
user_id,
|
||||
};
|
||||
use tokio::runtime::Builder;
|
||||
use wiremock::{Request, ResponseTemplate};
|
||||
@@ -70,8 +68,8 @@ pub fn receive_all_members_benchmark(c: &mut Criterion) {
|
||||
runtime
|
||||
.block_on(base_client.activate(
|
||||
SessionMeta {
|
||||
user_id: user_id!("@somebody:example.com").to_owned(),
|
||||
device_id: device_id!("DEVICE_ID").to_owned(),
|
||||
user_id: owned_user_id!("@somebody:example.com"),
|
||||
device_id: owned_device_id!("DEVICE_ID"),
|
||||
},
|
||||
RoomLoadSettings::default(),
|
||||
None,
|
||||
|
||||
@@ -8,7 +8,7 @@ use matrix_sdk::{
|
||||
};
|
||||
use matrix_sdk_base::{SessionMeta, StateStore as _, store::MemoryStore};
|
||||
use matrix_sdk_sqlite::SqliteStateStore;
|
||||
use ruma::{RoomId, device_id, user_id};
|
||||
use ruma::{RoomId, owned_device_id, owned_user_id};
|
||||
use tokio::runtime::Builder;
|
||||
|
||||
/// Number of joined rooms in the benchmark.
|
||||
@@ -35,8 +35,8 @@ pub fn restore_session(c: &mut Criterion) {
|
||||
|
||||
let session = MatrixSession {
|
||||
meta: SessionMeta {
|
||||
user_id: user_id!("@somebody:example.com").to_owned(),
|
||||
device_id: device_id!("DEVICE_ID").to_owned(),
|
||||
user_id: owned_user_id!("@somebody:example.com"),
|
||||
device_id: owned_device_id!("DEVICE_ID"),
|
||||
},
|
||||
tokens: SessionTokens { access_token: "OHEY".to_owned(), refresh_token: None },
|
||||
};
|
||||
|
||||
@@ -551,7 +551,7 @@ mod tests {
|
||||
name::{PossiblyRedactedRoomNameEventContent, RoomNameEventContent},
|
||||
},
|
||||
},
|
||||
room_alias_id, room_id,
|
||||
owned_room_alias_id, owned_user_id, room_alias_id, room_id,
|
||||
serde::Raw,
|
||||
user_id,
|
||||
};
|
||||
@@ -587,7 +587,7 @@ mod tests {
|
||||
fn make_canonical_alias_event() -> MinimalStateEvent<RoomCanonicalAliasEventContent> {
|
||||
MinimalStateEvent {
|
||||
content: assign!(PossiblyRedactedRoomCanonicalAliasEventContent::new(), {
|
||||
alias: Some(room_alias_id!("#test:example.com").to_owned()),
|
||||
alias: Some(owned_room_alias_id!("#test:example.com")),
|
||||
}),
|
||||
event_id: None,
|
||||
}
|
||||
@@ -1035,27 +1035,27 @@ mod tests {
|
||||
None,
|
||||
vec![
|
||||
RoomHero {
|
||||
user_id: user_id!("@alice:example.org").to_owned(),
|
||||
user_id: owned_user_id!("@alice:example.org"),
|
||||
display_name: Some("Alice".to_owned()),
|
||||
avatar_url: None,
|
||||
},
|
||||
RoomHero {
|
||||
user_id: user_id!("@bob:example.org").to_owned(),
|
||||
user_id: owned_user_id!("@bob:example.org"),
|
||||
display_name: Some("Bob".to_owned()),
|
||||
avatar_url: None,
|
||||
},
|
||||
RoomHero {
|
||||
user_id: user_id!("@carol:example.org").to_owned(),
|
||||
user_id: owned_user_id!("@carol:example.org"),
|
||||
display_name: Some("Carol".to_owned()),
|
||||
avatar_url: None,
|
||||
},
|
||||
RoomHero {
|
||||
user_id: user_id!("@denis:example.org").to_owned(),
|
||||
user_id: owned_user_id!("@denis:example.org"),
|
||||
display_name: Some("Denis".to_owned()),
|
||||
avatar_url: None,
|
||||
},
|
||||
RoomHero {
|
||||
user_id: user_id!("@erica:example.org").to_owned(),
|
||||
user_id: owned_user_id!("@erica:example.org"),
|
||||
display_name: Some("Erica".to_owned()),
|
||||
avatar_url: None,
|
||||
},
|
||||
|
||||
@@ -958,7 +958,7 @@ mod tests {
|
||||
// When I send sliding sync response containing a room with an avatar
|
||||
let room = {
|
||||
let mut room = http::response::Room::new();
|
||||
room.avatar = JsOption::from_option(Some(mxc_uri!("mxc://e.uk/med1").to_owned()));
|
||||
room.avatar = JsOption::from_option(Some(owned_mxc_uri!("mxc://e.uk/med1")));
|
||||
|
||||
room
|
||||
};
|
||||
@@ -987,7 +987,7 @@ mod tests {
|
||||
// When I send sliding sync response containing a room with an avatar
|
||||
let room = {
|
||||
let mut room = http::response::Room::new();
|
||||
room.avatar = JsOption::from_option(Some(mxc_uri!("mxc://e.uk/med1").to_owned()));
|
||||
room.avatar = JsOption::from_option(Some(owned_mxc_uri!("mxc://e.uk/med1")));
|
||||
|
||||
room
|
||||
};
|
||||
@@ -1333,8 +1333,8 @@ mod tests {
|
||||
// Given a logged-in client
|
||||
let client = logged_in_base_client(None).await;
|
||||
let room_id = room_id!("!r:e.uk");
|
||||
let gordon = user_id!("@gordon:e.uk").to_owned();
|
||||
let alice = user_id!("@alice:e.uk").to_owned();
|
||||
let gordon = owned_user_id!("@gordon:e.uk");
|
||||
let alice = owned_user_id!("@alice:e.uk");
|
||||
|
||||
// When I send sliding sync response containing a room (with identifiable data
|
||||
// in `heroes`)
|
||||
|
||||
@@ -1483,10 +1483,10 @@ mod tests {
|
||||
use assert_matches2::assert_let;
|
||||
use insta::{assert_json_snapshot, with_settings};
|
||||
use ruma::{
|
||||
DeviceKeyAlgorithm, MilliSecondsSinceUnixEpoch, UInt, device_id, event_id,
|
||||
DeviceKeyAlgorithm, MilliSecondsSinceUnixEpoch, UInt, event_id,
|
||||
events::{AnySyncTimelineEvent, room::message::RoomMessageEventContent},
|
||||
owned_device_id, owned_event_id, owned_user_id,
|
||||
serde::Raw,
|
||||
user_id,
|
||||
};
|
||||
use serde::Deserialize;
|
||||
use serde_json::json;
|
||||
@@ -1635,7 +1635,7 @@ mod tests {
|
||||
kind: TimelineEventKind::Decrypted(DecryptedRoomEvent {
|
||||
event: Raw::new(&example_event()).unwrap().cast_unchecked(),
|
||||
encryption_info: Arc::new(EncryptionInfo {
|
||||
sender: user_id!("@sender:example.com").to_owned(),
|
||||
sender: owned_user_id!("@sender:example.com"),
|
||||
sender_device: None,
|
||||
forwarder: None,
|
||||
algorithm_info: AlgorithmInfo::MegolmV1AesSha2 {
|
||||
@@ -1702,7 +1702,7 @@ mod tests {
|
||||
|
||||
// And it can be properly deserialized from the new format.
|
||||
let event: TimelineEvent = serde_json::from_value(serialized).unwrap();
|
||||
assert_eq!(event.event_id(), Some(event_id!("$xxxxx:example.org").to_owned()));
|
||||
assert_eq!(event.event_id(), Some(owned_event_id!("$xxxxx:example.org")));
|
||||
assert_matches!(
|
||||
event.encryption_info().unwrap().algorithm_info,
|
||||
AlgorithmInfo::MegolmV1AesSha2 { .. }
|
||||
@@ -1733,7 +1733,7 @@ mod tests {
|
||||
},
|
||||
});
|
||||
let event: TimelineEvent = serde_json::from_value(serialized).unwrap();
|
||||
assert_eq!(event.event_id(), Some(event_id!("$xxxxx:example.org").to_owned()));
|
||||
assert_eq!(event.event_id(), Some(owned_event_id!("$xxxxx:example.org")));
|
||||
assert_matches!(
|
||||
event.encryption_info().unwrap().algorithm_info,
|
||||
AlgorithmInfo::MegolmV1AesSha2 { session_id: None, .. }
|
||||
@@ -1768,7 +1768,7 @@ mod tests {
|
||||
}
|
||||
});
|
||||
let event: TimelineEvent = serde_json::from_value(serialized).unwrap();
|
||||
assert_eq!(event.event_id(), Some(event_id!("$xxxxx:example.org").to_owned()));
|
||||
assert_eq!(event.event_id(), Some(owned_event_id!("$xxxxx:example.org")));
|
||||
assert_matches!(
|
||||
event.encryption_info().unwrap().algorithm_info,
|
||||
AlgorithmInfo::MegolmV1AesSha2 { .. }
|
||||
@@ -2060,8 +2060,8 @@ mod tests {
|
||||
#[test]
|
||||
fn snapshot_test_encryption_info() {
|
||||
let info = EncryptionInfo {
|
||||
sender: user_id!("@alice:localhost").to_owned(),
|
||||
sender_device: Some(device_id!("ABCDEFGH").to_owned()),
|
||||
sender: owned_user_id!("@alice:localhost"),
|
||||
sender_device: Some(owned_device_id!("ABCDEFGH")),
|
||||
forwarder: None,
|
||||
algorithm_info: AlgorithmInfo::MegolmV1AesSha2 {
|
||||
curve25519_key: "curvecurvecurve".into(),
|
||||
@@ -2082,8 +2082,8 @@ mod tests {
|
||||
kind: TimelineEventKind::Decrypted(DecryptedRoomEvent {
|
||||
event: Raw::new(&example_event()).unwrap().cast_unchecked(),
|
||||
encryption_info: Arc::new(EncryptionInfo {
|
||||
sender: user_id!("@sender:example.com").to_owned(),
|
||||
sender_device: Some(device_id!("ABCDEFGHIJ").to_owned()),
|
||||
sender: owned_user_id!("@sender:example.com"),
|
||||
sender_device: Some(owned_device_id!("ABCDEFGHIJ")),
|
||||
forwarder: None,
|
||||
algorithm_info: AlgorithmInfo::MegolmV1AesSha2 {
|
||||
curve25519_key: "xxx".to_owned(),
|
||||
|
||||
@@ -1118,12 +1118,12 @@ mod tests {
|
||||
use assert_matches::assert_matches;
|
||||
use matrix_sdk_test::{async_test, message_like_event_content};
|
||||
use ruma::{
|
||||
DeviceId, RoomId, UserId, device_id, event_id,
|
||||
DeviceId, RoomId, UserId, device_id,
|
||||
events::{
|
||||
ToDeviceEvent as RumaToDeviceEvent,
|
||||
secret::request::{RequestAction, SecretName, ToDeviceSecretRequestEventContent},
|
||||
},
|
||||
room_id,
|
||||
owned_event_id, room_id,
|
||||
serde::Raw,
|
||||
user_id,
|
||||
};
|
||||
@@ -1237,14 +1237,14 @@ mod tests {
|
||||
}
|
||||
|
||||
async fn get_machine_test_helper() -> GossipMachine {
|
||||
let user_id = alice_id().to_owned();
|
||||
let account = Account::with_device_id(&user_id, alice_device_id());
|
||||
let user_id = alice_id();
|
||||
let account = Account::with_device_id(user_id, alice_device_id());
|
||||
let device = DeviceData::from_account(&account);
|
||||
let another_device =
|
||||
DeviceData::from_account(&Account::with_device_id(&user_id, alice2_device_id()));
|
||||
DeviceData::from_account(&Account::with_device_id(user_id, alice2_device_id()));
|
||||
|
||||
let store =
|
||||
Arc::new(CryptoStoreWrapper::new(&user_id, account.device_id(), MemoryStore::new()));
|
||||
Arc::new(CryptoStoreWrapper::new(user_id, account.device_id(), MemoryStore::new()));
|
||||
let identity = Arc::new(Mutex::new(PrivateCrossSigningIdentity::empty(alice_id())));
|
||||
let verification =
|
||||
VerificationMachine::new(account.static_data.clone(), identity.clone(), store.clone());
|
||||
@@ -1378,7 +1378,7 @@ mod tests {
|
||||
|
||||
EncryptedEvent {
|
||||
sender: sender.to_owned(),
|
||||
event_id: event_id!("$143273582443PhrSn:example.org").to_owned(),
|
||||
event_id: owned_event_id!("$143273582443PhrSn:example.org"),
|
||||
#[cfg(feature = "experimental-encrypted-state-events")]
|
||||
state_key: None,
|
||||
content,
|
||||
|
||||
@@ -2656,8 +2656,8 @@ impl OlmMachine {
|
||||
///
|
||||
/// ```
|
||||
/// # use matrix_sdk_crypto::OlmMachine;
|
||||
/// # use ruma::{device_id, user_id};
|
||||
/// # let alice = user_id!("@alice:example.org").to_owned();
|
||||
/// # use ruma::{device_id, owned_user_id};
|
||||
/// # let alice = owned_user_id!("@alice:example.org");
|
||||
/// # futures_executor::block_on(async {
|
||||
/// # let machine = OlmMachine::new(&alice, device_id!("DEVICEID")).await;
|
||||
/// let device = machine.get_device(&alice, device_id!("DEVICEID"), None).await;
|
||||
@@ -2714,8 +2714,8 @@ impl OlmMachine {
|
||||
///
|
||||
/// ```
|
||||
/// # use matrix_sdk_crypto::OlmMachine;
|
||||
/// # use ruma::{device_id, user_id};
|
||||
/// # let alice = user_id!("@alice:example.org").to_owned();
|
||||
/// # use ruma::{device_id, owned_user_id};
|
||||
/// # let alice = owned_user_id!("@alice:example.org");
|
||||
/// # futures_executor::block_on(async {
|
||||
/// # let machine = OlmMachine::new(&alice, device_id!("DEVICEID")).await;
|
||||
/// let devices = machine.get_user_devices(&alice, None).await.unwrap();
|
||||
|
||||
@@ -46,7 +46,7 @@ use ruma::{
|
||||
AddMentions, MessageType, Relation, ReplyWithinThread, RoomMessageEventContent,
|
||||
},
|
||||
},
|
||||
room_id,
|
||||
owned_room_id, room_id,
|
||||
serde::Raw,
|
||||
uint, user_id,
|
||||
};
|
||||
@@ -1664,7 +1664,7 @@ async fn test_fix_incorrect_usage_of_backup_key_causing_decryption_errors() {
|
||||
let alice = OlmMachine::with_store(user_id(), alice_device_id(), store, None).await.unwrap();
|
||||
|
||||
let exported_key = ExportedRoomKey::from_backed_up_room_key(
|
||||
room_id!("!room:id").to_owned(),
|
||||
owned_room_id!("!room:id"),
|
||||
"/2K+V777vipCxPZ0gpY9qcpz1DYaXwuMRIu0UEP0Wa0".into(),
|
||||
backed_up_room_key,
|
||||
);
|
||||
@@ -1673,7 +1673,7 @@ async fn test_fix_incorrect_usage_of_backup_key_causing_decryption_errors() {
|
||||
|
||||
let (_, request) = alice.backup_machine().backup().await.unwrap().unwrap();
|
||||
|
||||
let key_backup_data = request.rooms[&room_id!("!room:id").to_owned()]
|
||||
let key_backup_data = request.rooms[&owned_room_id!("!room:id")]
|
||||
.sessions
|
||||
.get("/2K+V777vipCxPZ0gpY9qcpz1DYaXwuMRIu0UEP0Wa0")
|
||||
.unwrap()
|
||||
|
||||
@@ -769,8 +769,7 @@ mod tests {
|
||||
|
||||
#[async_test]
|
||||
async fn test_from_device_for_unverified_user() {
|
||||
let bob_identity =
|
||||
PrivateCrossSigningIdentity::new(user_id!("@bob:example.com").to_owned());
|
||||
let bob_identity = PrivateCrossSigningIdentity::new(owned_user_id!("@bob:example.com"));
|
||||
let bob_account =
|
||||
Account::with_device_id(user_id!("@bob:example.com"), device_id!("BOB_DEVICE"));
|
||||
let bob_device = create_signed_device_of_unverified_user(
|
||||
@@ -799,8 +798,7 @@ mod tests {
|
||||
Account::with_device_id(user_id!("@alice:example.com"), device_id!("ALICE_DEVICE"));
|
||||
let alice_identity = PrivateCrossSigningIdentity::for_account(&alice_account);
|
||||
|
||||
let bob_identity =
|
||||
PrivateCrossSigningIdentity::new(user_id!("@bob:example.com").to_owned());
|
||||
let bob_identity = PrivateCrossSigningIdentity::new(owned_user_id!("@bob:example.com"));
|
||||
let bob_account =
|
||||
Account::with_device_id(user_id!("@bob:example.com"), device_id!("BOB_DEVICE"));
|
||||
let bob_device = create_signed_device_of_verified_user(
|
||||
@@ -826,8 +824,7 @@ mod tests {
|
||||
|
||||
#[async_test]
|
||||
async fn test_from_device_for_verification_violation_user() {
|
||||
let bob_identity =
|
||||
PrivateCrossSigningIdentity::new(user_id!("@bob:example.com").to_owned());
|
||||
let bob_identity = PrivateCrossSigningIdentity::new(owned_user_id!("@bob:example.com"));
|
||||
let bob_account =
|
||||
Account::with_device_id(user_id!("@bob:example.com"), device_id!("BOB_DEVICE"));
|
||||
let bob_device =
|
||||
|
||||
@@ -1100,7 +1100,7 @@ mod tests {
|
||||
events::room::{
|
||||
EncryptedFileInit, JsonWebKey, JsonWebKeyInit, history_visibility::HistoryVisibility,
|
||||
},
|
||||
owned_room_id, room_id,
|
||||
owned_device_id, owned_room_id, room_id,
|
||||
serde::Base64,
|
||||
to_device::DeviceIdOrAllDevices,
|
||||
user_id,
|
||||
@@ -1584,7 +1584,7 @@ mod tests {
|
||||
// One should be blacklisted
|
||||
let has_blacklist =
|
||||
requests.iter().filter(|r| r.event_type == "m.room_key.withheld".into()).any(|r| {
|
||||
let device_key = DeviceIdOrAllDevices::from(device_id!("MWVTUXDNNM").to_owned());
|
||||
let device_key = DeviceIdOrAllDevices::from(owned_device_id!("MWVTUXDNNM"));
|
||||
let content = &r.messages[user_id][&device_key];
|
||||
let withheld: RoomKeyWithheldContent =
|
||||
content.deserialize_as_unchecked::<RoomKeyWithheldContent>().unwrap();
|
||||
|
||||
@@ -39,7 +39,7 @@ macro_rules! cryptostore_integration_tests {
|
||||
use assert_matches::assert_matches;
|
||||
use matrix_sdk_test::async_test;
|
||||
use ruma::{
|
||||
device_id, events::secret::request::SecretName, room_id, serde::Raw,
|
||||
device_id, events::secret::request::SecretName, room_id, serde::Raw, owned_room_id,
|
||||
to_device::DeviceIdOrAllDevices, user_id, DeviceId, RoomId, TransactionId, UserId,
|
||||
};
|
||||
use serde_json::value::to_raw_value;
|
||||
@@ -1005,7 +1005,7 @@ macro_rules! cryptostore_integration_tests {
|
||||
|
||||
let id = TransactionId::new();
|
||||
let info: SecretInfo = MegolmV1AesSha2Content {
|
||||
room_id: room_id!("!test:localhost").to_owned(),
|
||||
room_id: owned_room_id!("!test:localhost"),
|
||||
sender_key: Some(sender_key),
|
||||
session_id: "test_session_id".to_owned(),
|
||||
}
|
||||
@@ -1066,7 +1066,7 @@ macro_rules! cryptostore_integration_tests {
|
||||
|
||||
let id = TransactionId::new();
|
||||
let info: SecretInfo = MegolmV1AesSha2Content {
|
||||
room_id: room_id!("!test:localhost").to_owned(),
|
||||
room_id: owned_room_id!("!test:localhost"),
|
||||
sender_key: Some(account.identity_keys().curve25519),
|
||||
session_id: "test_session_id".to_owned(),
|
||||
}
|
||||
@@ -1376,7 +1376,7 @@ macro_rules! cryptostore_integration_tests {
|
||||
sender_key: Curve25519PublicKey::from_bytes([0u8; 32]),
|
||||
sender_data: SenderData::unknown(),
|
||||
bundle_data: RoomKeyBundleContent {
|
||||
room_id: room_id!("!room:example.org").to_owned(),
|
||||
room_id: owned_room_id!("!room:example.org"),
|
||||
file,
|
||||
},
|
||||
}
|
||||
|
||||
@@ -1375,9 +1375,9 @@ impl Store {
|
||||
///
|
||||
/// ```no_run
|
||||
/// # use matrix_sdk_crypto::OlmMachine;
|
||||
/// # use ruma::{device_id, user_id};
|
||||
/// # use ruma::{device_id, owned_user_id};
|
||||
/// # use futures_util::{pin_mut, StreamExt};
|
||||
/// # let alice = user_id!("@alice:example.org").to_owned();
|
||||
/// # let alice = owned_user_id!("@alice:example.org");
|
||||
/// # futures_executor::block_on(async {
|
||||
/// # let machine = OlmMachine::new(&alice, device_id!("DEVICEID")).await;
|
||||
///
|
||||
@@ -1411,9 +1411,9 @@ impl Store {
|
||||
/// # store::types::StoredRoomKeyBundleData,
|
||||
/// # types::room_history::RoomKeyBundle
|
||||
/// # };
|
||||
/// # use ruma::{device_id, user_id};
|
||||
/// # use ruma::{device_id, owned_user_id};
|
||||
/// # use futures_util::{pin_mut, StreamExt};
|
||||
/// # let alice = user_id!("@alice:example.org").to_owned();
|
||||
/// # let alice = owned_user_id!("@alice:example.org");
|
||||
/// # async {
|
||||
/// # let machine = OlmMachine::new(&alice, device_id!("DEVICEID")).await;
|
||||
/// let bundle_stream = machine.store().historic_room_key_stream();
|
||||
|
||||
@@ -117,7 +117,7 @@ mod tests {
|
||||
|
||||
use assert_matches::assert_matches;
|
||||
use insta::{assert_json_snapshot, with_settings};
|
||||
use ruma::{DeviceKeyAlgorithm, KeyId, user_id};
|
||||
use ruma::{DeviceKeyAlgorithm, KeyId, owned_user_id};
|
||||
use serde_json::{Value, json};
|
||||
use vodozemac::{Curve25519PublicKey, Ed25519Signature};
|
||||
|
||||
@@ -163,7 +163,7 @@ mod tests {
|
||||
let info = RoomKeyBackupInfo::MegolmBackupV1Curve25519AesSha2(MegolmV1AuthData {
|
||||
public_key: Curve25519PublicKey::from_bytes([2u8; 32]),
|
||||
signatures: Signatures(BTreeMap::from([(
|
||||
user_id!("@alice:localhost").to_owned(),
|
||||
owned_user_id!("@alice:localhost"),
|
||||
BTreeMap::from([(
|
||||
KeyId::from_parts(DeviceKeyAlgorithm::Ed25519, "ABCDEFG".into()),
|
||||
Ok(Signature::from(Ed25519Signature::from_slice(&[0u8; 64]).unwrap())),
|
||||
|
||||
@@ -559,7 +559,7 @@ pub trait RoomKeyExport {
|
||||
#[cfg(test)]
|
||||
mod test {
|
||||
use insta::{assert_debug_snapshot, assert_json_snapshot, with_settings};
|
||||
use ruma::{device_id, user_id};
|
||||
use ruma::{device_id, owned_user_id};
|
||||
use serde_json::json;
|
||||
use similar_asserts::assert_eq;
|
||||
|
||||
@@ -602,7 +602,7 @@ mod test {
|
||||
fn snapshot_signatures() {
|
||||
let signatures = Signatures(BTreeMap::from([
|
||||
(
|
||||
user_id!("@alice:localhost").to_owned(),
|
||||
owned_user_id!("@alice:localhost"),
|
||||
BTreeMap::from([
|
||||
(
|
||||
DeviceKeyId::from_parts(
|
||||
@@ -621,7 +621,7 @@ mod test {
|
||||
]),
|
||||
),
|
||||
(
|
||||
user_id!("@bob:localhost").to_owned(),
|
||||
owned_user_id!("@bob:localhost"),
|
||||
BTreeMap::from([(
|
||||
DeviceKeyId::from_parts(DeviceKeyAlgorithm::Ed25519, device_id!("ABCDEFGH")),
|
||||
Err(InvalidSignature { source: "SOME+B64+SOME+B64+SOME+B64+==".to_owned() }),
|
||||
|
||||
@@ -893,7 +893,9 @@ mod tests {
|
||||
use assert_matches::assert_matches;
|
||||
use matrix_sdk_qrcode::QrVerificationData;
|
||||
use matrix_sdk_test::async_test;
|
||||
use ruma::{DeviceId, UserId, device_id, event_id, room_id, user_id};
|
||||
use ruma::{
|
||||
DeviceId, UserId, device_id, owned_event_id, owned_room_id, owned_user_id, user_id,
|
||||
};
|
||||
use tokio::sync::Mutex;
|
||||
|
||||
use crate::{
|
||||
@@ -966,12 +968,11 @@ mod tests {
|
||||
assert_eq!(verification.inner.first_key(), master_key);
|
||||
assert_eq!(verification.inner.second_key(), device_key);
|
||||
|
||||
let bob_identity = PrivateCrossSigningIdentity::new(user_id!("@bob:example").to_owned());
|
||||
let bob_identity = PrivateCrossSigningIdentity::new(owned_user_id!("@bob:example"));
|
||||
let bob_master_key = bob_identity.master_public_key().await.unwrap();
|
||||
let bob_master_key = bob_master_key.get_first_key().unwrap().to_owned();
|
||||
|
||||
let flow_id =
|
||||
FlowId::InRoom(room_id!("!test:example").to_owned(), event_id!("$EVENTID").to_owned());
|
||||
let flow_id = FlowId::InRoom(owned_room_id!("!test:example"), owned_event_id!("$EVENTID"));
|
||||
|
||||
let verification =
|
||||
QrVerification::new_cross(flow_id, master_key, bob_master_key, identities, false, None);
|
||||
@@ -1099,8 +1100,7 @@ mod tests {
|
||||
let flow_id = FlowId::ToDevice("test_transaction".into());
|
||||
test(flow_id).await;
|
||||
|
||||
let flow_id =
|
||||
FlowId::InRoom(room_id!("!test:example").to_owned(), event_id!("$EVENTID").to_owned());
|
||||
let flow_id = FlowId::InRoom(owned_room_id!("!test:example"), owned_event_id!("$EVENTID"));
|
||||
test(flow_id).await;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1632,8 +1632,8 @@ mod tests {
|
||||
use matrix_sdk_qrcode::QrVerificationData;
|
||||
use matrix_sdk_test::async_test;
|
||||
use ruma::{
|
||||
UserId, event_id, events::key::verification::VerificationMethod, room_id,
|
||||
to_device::DeviceIdOrAllDevices,
|
||||
UserId, event_id, events::key::verification::VerificationMethod, owned_event_id,
|
||||
owned_room_id, room_id, to_device::DeviceIdOrAllDevices,
|
||||
};
|
||||
|
||||
use super::VerificationRequest;
|
||||
@@ -1652,8 +1652,8 @@ mod tests {
|
||||
|
||||
#[async_test]
|
||||
async fn test_request_accepting() {
|
||||
let event_id = event_id!("$1234localhost").to_owned();
|
||||
let room_id = room_id!("!test:localhost").to_owned();
|
||||
let event_id = owned_event_id!("$1234localhost");
|
||||
let room_id = owned_room_id!("!test:localhost");
|
||||
|
||||
let (alice, alice_store, bob, bob_store) = setup_stores().await;
|
||||
|
||||
|
||||
@@ -285,7 +285,7 @@ mod tests {
|
||||
};
|
||||
use matrix_sdk_store_encryption::StoreCipher;
|
||||
use matrix_sdk_test::async_test;
|
||||
use ruma::{OwnedRoomId, RoomId, device_id, owned_user_id, room_id};
|
||||
use ruma::{OwnedRoomId, RoomId, owned_device_id, owned_user_id, room_id};
|
||||
use serde::Serialize;
|
||||
use tracing_subscriber::util::SubscriberInitExt;
|
||||
use wasm_bindgen::JsValue;
|
||||
@@ -872,7 +872,7 @@ mod tests {
|
||||
room_id.to_owned(),
|
||||
session_id.to_owned(),
|
||||
sender_key,
|
||||
device_id!("ABC").to_owned(),
|
||||
owned_device_id!("ABC"),
|
||||
),
|
||||
};
|
||||
|
||||
|
||||
@@ -2112,7 +2112,7 @@ mod wasm_unit_tests {
|
||||
types::{DeviceKeys, Signatures},
|
||||
};
|
||||
use matrix_sdk_test::async_test;
|
||||
use ruma::{device_id, user_id};
|
||||
use ruma::{owned_device_id, owned_user_id};
|
||||
use wasm_bindgen::JsValue;
|
||||
|
||||
use crate::crypto_store::unit_tests::sender_data_test_session;
|
||||
@@ -2148,8 +2148,8 @@ mod wasm_unit_tests {
|
||||
let sender_key = Curve25519PublicKey::from_bytes([0; 32]);
|
||||
|
||||
let sender_data = SenderData::device_info(DeviceKeys::new(
|
||||
user_id!("@test:user").to_owned(),
|
||||
device_id!("ABC").to_owned(),
|
||||
owned_user_id!("@test:user"),
|
||||
owned_device_id!("ABC"),
|
||||
vec![],
|
||||
BTreeMap::new(),
|
||||
Signatures::new(),
|
||||
|
||||
@@ -183,9 +183,9 @@ mod tests {
|
||||
fn test_add_edge_and_root_nodes() {
|
||||
let mut graph = SpaceGraph::new();
|
||||
|
||||
let a = room_id!("!a:example.org").to_owned();
|
||||
let b = room_id!("!b:example.org").to_owned();
|
||||
let c = room_id!("!c:example.org").to_owned();
|
||||
let a = owned_room_id!("!a:example.org");
|
||||
let b = owned_room_id!("!b:example.org");
|
||||
let c = owned_room_id!("!c:example.org");
|
||||
|
||||
graph.add_edge(a.clone(), b.clone());
|
||||
graph.add_edge(a.clone(), c.clone());
|
||||
@@ -202,9 +202,9 @@ mod tests {
|
||||
fn test_remove_cycles() {
|
||||
let mut graph = SpaceGraph::new();
|
||||
|
||||
let a = room_id!("!a:example.org").to_owned();
|
||||
let b = room_id!("!b:example.org").to_owned();
|
||||
let c = room_id!("!c:example.org").to_owned();
|
||||
let a = owned_room_id!("!a:example.org");
|
||||
let b = owned_room_id!("!b:example.org");
|
||||
let c = owned_room_id!("!c:example.org");
|
||||
|
||||
graph.add_edge(a.clone(), b.clone());
|
||||
graph.add_edge(b, c.clone());
|
||||
@@ -222,12 +222,12 @@ mod tests {
|
||||
fn test_disconnected_graph_roots() {
|
||||
let mut graph = SpaceGraph::new();
|
||||
|
||||
let a = room_id!("!a:example.org").to_owned();
|
||||
let b = room_id!("!b:example.org").to_owned();
|
||||
let a = owned_room_id!("!a:example.org");
|
||||
let b = owned_room_id!("!b:example.org");
|
||||
graph.add_edge(a.clone(), b);
|
||||
|
||||
let x = room_id!("!x:example.org").to_owned();
|
||||
let y = room_id!("!y:example.org").to_owned();
|
||||
let x = owned_room_id!("!x:example.org");
|
||||
let y = owned_room_id!("!y:example.org");
|
||||
graph.add_edge(x.clone(), y);
|
||||
|
||||
let mut roots = graph.root_nodes();
|
||||
@@ -241,10 +241,10 @@ mod tests {
|
||||
fn test_multiple_parents() {
|
||||
let mut graph = SpaceGraph::new();
|
||||
|
||||
let a = room_id!("!a:example.org").to_owned();
|
||||
let b = room_id!("!b:example.org").to_owned();
|
||||
let c = room_id!("!c:example.org").to_owned();
|
||||
let d = room_id!("!d:example.org").to_owned();
|
||||
let a = owned_room_id!("!a:example.org");
|
||||
let b = owned_room_id!("!b:example.org");
|
||||
let c = owned_room_id!("!c:example.org");
|
||||
let d = owned_room_id!("!d:example.org");
|
||||
|
||||
graph.add_edge(a.clone(), c.clone());
|
||||
graph.add_edge(b.clone(), c.clone());
|
||||
|
||||
@@ -251,7 +251,7 @@ mod tests {
|
||||
use ruma::{
|
||||
MilliSecondsSinceUnixEpoch, event_id,
|
||||
events::{AnyMessageLikeEventContent, room::message::RoomMessageEventContent},
|
||||
room_id, uint, user_id,
|
||||
owned_event_id, room_id, uint, user_id,
|
||||
};
|
||||
|
||||
use super::{
|
||||
@@ -362,7 +362,7 @@ mod tests {
|
||||
let room = server.sync_room(&client, JoinedRoomBuilder::new(room_id!("!r0"))).await;
|
||||
|
||||
let base_value = BaseLatestEventValue::LocalHasBeenSent {
|
||||
event_id: event_id!("$ev0").to_owned(),
|
||||
event_id: owned_event_id!("$ev0"),
|
||||
value: LocalLatestEventValue {
|
||||
timestamp: MilliSecondsSinceUnixEpoch(uint!(42)),
|
||||
content: SerializableEventContent::new(&AnyMessageLikeEventContent::RoomMessage(
|
||||
|
||||
@@ -152,10 +152,10 @@ async fn test_sticker() {
|
||||
let item = assert_next_matches!(stream, VectorDiff::PushBack { value } => value);
|
||||
assert!(item.content().is_sticker());
|
||||
|
||||
assert_eq!(item.content().thread_root(), Some(event_id!("$thread_root").to_owned()));
|
||||
assert_eq!(item.content().thread_root(), Some(owned_event_id!("$thread_root")));
|
||||
|
||||
assert_let!(Some(details) = item.content().in_reply_to());
|
||||
assert_eq!(details.event_id, event_id!("$in_reply_to").to_owned())
|
||||
assert_eq!(details.event_id, owned_event_id!("$in_reply_to"))
|
||||
}
|
||||
|
||||
#[async_test]
|
||||
|
||||
@@ -19,8 +19,8 @@ use eyeball_im::VectorDiff;
|
||||
use futures_util::{FutureExt, StreamExt as _};
|
||||
use matrix_sdk_test::{ALICE, BOB, async_test};
|
||||
use ruma::{
|
||||
event_id,
|
||||
events::{AnyMessageLikeEventContent, room::message::RoomMessageEventContent},
|
||||
owned_event_id,
|
||||
};
|
||||
use stream_assert::assert_next_matches;
|
||||
|
||||
@@ -152,7 +152,7 @@ async fn test_update_read_marker() {
|
||||
assert!(stream.next().now_or_never().is_none());
|
||||
|
||||
// Nothing should happen if the fully read event isn't found.
|
||||
timeline.controller.handle_fully_read_marker(event_id!("$fake_event_id").to_owned()).await;
|
||||
timeline.controller.handle_fully_read_marker(owned_event_id!("$fake_event_id")).await;
|
||||
assert!(stream.next().now_or_never().is_none());
|
||||
|
||||
// Nothing should happen if the fully read event is referring to an event
|
||||
|
||||
@@ -407,7 +407,7 @@ impl Drop for UtdHookManager {
|
||||
mod tests {
|
||||
use matrix_sdk::test_utils::{logged_in_client, no_retry_test_client};
|
||||
use matrix_sdk_test::async_test;
|
||||
use ruma::{event_id, server_name, user_id};
|
||||
use ruma::{event_id, owned_server_name, server_name, user_id};
|
||||
|
||||
use super::*;
|
||||
|
||||
@@ -461,10 +461,10 @@ mod tests {
|
||||
assert!(utd_local_age <= 1000);
|
||||
|
||||
assert_eq!(utds[0].sender_homeserver, server_name!("localhost"));
|
||||
assert_eq!(utds[0].own_homeserver, Some(server_name!("localhost").to_owned()));
|
||||
assert_eq!(utds[0].own_homeserver, Some(owned_server_name!("localhost")));
|
||||
|
||||
assert_eq!(utds[1].sender_homeserver, server_name!("example.com"));
|
||||
assert_eq!(utds[1].own_homeserver, Some(server_name!("localhost").to_owned()));
|
||||
assert_eq!(utds[1].own_homeserver, Some(owned_server_name!("localhost")));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -27,7 +27,7 @@ use matrix_sdk_ui::{
|
||||
use ruma::{
|
||||
api::client::room::create_room::v3::Request as CreateRoomRequest,
|
||||
events::room::message::RoomMessageEventContent,
|
||||
mxc_uri, room_id,
|
||||
owned_mxc_uri, room_id,
|
||||
time::{Duration, Instant},
|
||||
};
|
||||
use serde_json::json;
|
||||
@@ -2203,7 +2203,7 @@ async fn test_room() -> Result<(), Error> {
|
||||
assert_eq!(room0.cached_display_name(), Some(RoomDisplayName::Named("Room #0".to_owned())));
|
||||
|
||||
// Room has received an avatar from sliding sync.
|
||||
assert_eq!(room0.avatar_url(), Some(mxc_uri!("mxc://homeserver/media").to_owned()));
|
||||
assert_eq!(room0.avatar_url(), Some(owned_mxc_uri!("mxc://homeserver/media")));
|
||||
|
||||
let room1 = room_list.room(room_id_1)?;
|
||||
|
||||
@@ -2248,7 +2248,7 @@ async fn test_room() -> Result<(), Error> {
|
||||
assert_eq!(room1.cached_display_name(), Some(RoomDisplayName::Named("Room #1".to_owned())));
|
||||
|
||||
// Room has _now_ received an avatar URL from sliding sync!
|
||||
assert_eq!(room1.avatar_url(), Some(mxc_uri!("mxc://homeserver/other-media").to_owned()));
|
||||
assert_eq!(room1.avatar_url(), Some(owned_mxc_uri!("mxc://homeserver/other-media")));
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
@@ -664,7 +664,7 @@ impl MatrixAuth {
|
||||
/// use matrix_sdk::{
|
||||
/// Client, SessionMeta, SessionTokens,
|
||||
/// authentication::matrix::MatrixSession,
|
||||
/// ruma::{device_id, user_id},
|
||||
/// ruma::{owned_device_id, owned_user_id},
|
||||
/// };
|
||||
/// # use url::Url;
|
||||
/// # async {
|
||||
@@ -674,8 +674,8 @@ impl MatrixAuth {
|
||||
///
|
||||
/// let session = MatrixSession {
|
||||
/// meta: SessionMeta {
|
||||
/// user_id: user_id!("@example:localhost").to_owned(),
|
||||
/// device_id: device_id!("MYDEVICEID").to_owned(),
|
||||
/// user_id: owned_user_id!("@example:localhost"),
|
||||
/// device_id: owned_device_id!("MYDEVICEID"),
|
||||
/// },
|
||||
/// tokens: SessionTokens {
|
||||
/// access_token: "My-Token".to_owned(),
|
||||
@@ -817,12 +817,12 @@ impl MatrixAuth {
|
||||
/// use matrix_sdk::{
|
||||
/// SessionMeta, SessionTokens, authentication::matrix::MatrixSession,
|
||||
/// };
|
||||
/// use ruma::{device_id, user_id};
|
||||
/// use ruma::{owned_device_id, owned_user_id};
|
||||
///
|
||||
/// let session = MatrixSession {
|
||||
/// meta: SessionMeta {
|
||||
/// user_id: user_id!("@example:localhost").to_owned(),
|
||||
/// device_id: device_id!("MYDEVICEID").to_owned(),
|
||||
/// user_id: owned_user_id!("@example:localhost"),
|
||||
/// device_id: owned_device_id!("MYDEVICEID"),
|
||||
/// },
|
||||
/// tokens: SessionTokens {
|
||||
/// access_token: "My-Token".to_owned(),
|
||||
@@ -830,7 +830,7 @@ impl MatrixAuth {
|
||||
/// },
|
||||
/// };
|
||||
///
|
||||
/// assert_eq!(session.meta.device_id.as_str(), "MYDEVICEID");
|
||||
/// assert_eq!(session.meta.device_id, "MYDEVICEID");
|
||||
/// ```
|
||||
#[derive(Clone, Eq, Hash, PartialEq, Serialize, Deserialize)]
|
||||
pub struct MatrixSession {
|
||||
|
||||
@@ -1900,12 +1900,12 @@ impl Client {
|
||||
/// # async {
|
||||
/// # let homeserver = Url::parse("http://localhost:8080")?;
|
||||
/// # let mut client = Client::new(homeserver).await?;
|
||||
/// use matrix_sdk::ruma::{api::client::profile, user_id};
|
||||
/// use matrix_sdk::ruma::{api::client::profile, owned_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").to_owned();
|
||||
/// let user_id = owned_user_id!("@example:localhost");
|
||||
/// let request = profile::get_profile::v3::Request::new(user_id);
|
||||
///
|
||||
/// // Start the request using Client::send()
|
||||
@@ -2517,7 +2517,7 @@ impl Client {
|
||||
///
|
||||
/// ```no_run
|
||||
/// # use matrix_sdk::{
|
||||
/// # ruma::{api::client::uiaa, device_id},
|
||||
/// # ruma::{api::client::uiaa, owned_device_id},
|
||||
/// # Client, Error, config::SyncSettings,
|
||||
/// # };
|
||||
/// # use serde_json::json;
|
||||
@@ -2526,7 +2526,7 @@ impl Client {
|
||||
/// # async {
|
||||
/// # let homeserver = Url::parse("http://localhost:8080")?;
|
||||
/// # let mut client = Client::new(homeserver).await?;
|
||||
/// let devices = &[device_id!("DEVICEID").to_owned()];
|
||||
/// let devices = &[owned_device_id!("DEVICEID")];
|
||||
///
|
||||
/// if let Err(e) = client.delete_devices(devices, None).await {
|
||||
/// if let Some(info) = e.as_uiaa_response() {
|
||||
|
||||
@@ -788,7 +788,7 @@ mod filter_tests {
|
||||
room::{member::MembershipState, message::RoomMessageEventContent},
|
||||
rtc::notification::NotificationType,
|
||||
},
|
||||
owned_user_id, user_id,
|
||||
owned_event_id, owned_user_id, user_id,
|
||||
};
|
||||
|
||||
use super::{ControlFlow, FilterContinue, filter_timeline_event};
|
||||
@@ -868,7 +868,7 @@ mod filter_tests {
|
||||
// `current_value_event_id` is `Some(_)`, but the redaction event doesn't target
|
||||
// this event ID.
|
||||
{
|
||||
let current_value_event_id = Some(event_id!("$ev1").to_owned());
|
||||
let current_value_event_id = Some(owned_event_id!("$ev1"));
|
||||
|
||||
assert_matches!(
|
||||
filter_timeline_event(&event, current_value_event_id.as_ref(), user_id, None),
|
||||
@@ -1279,7 +1279,7 @@ mod filter_tests {
|
||||
"body".to_owned(),
|
||||
vec![],
|
||||
OwnedDeviceId::from("device_id"),
|
||||
user_id!("@user:server.name").to_owned(),
|
||||
owned_user_id!("@user:server.name"),
|
||||
),
|
||||
)))
|
||||
.into_event()
|
||||
@@ -1611,7 +1611,7 @@ mod builder_tests {
|
||||
SyncMessageLikeEvent, reaction::ReactionEventContent, relation::Annotation,
|
||||
room::message::RoomMessageEventContent,
|
||||
},
|
||||
room_id,
|
||||
owned_event_id, owned_room_id, room_id,
|
||||
serde::Raw,
|
||||
user_id,
|
||||
};
|
||||
@@ -2492,7 +2492,7 @@ mod builder_tests {
|
||||
}
|
||||
|
||||
async fn local_prelude() -> (Client, OwnedRoomId, RoomSendQueue, RoomEventCache) {
|
||||
let room_id = room_id!("!r0").to_owned();
|
||||
let room_id = owned_room_id!("!r0");
|
||||
|
||||
let server = MatrixMockServer::new().await;
|
||||
let client = server.client_builder().build().await;
|
||||
@@ -2862,7 +2862,7 @@ mod builder_tests {
|
||||
let previous_value = {
|
||||
let update = RoomSendQueueUpdate::SentEvent {
|
||||
transaction_id: transaction_id_0.clone(),
|
||||
event_id: event_id!("$ev0").to_owned(),
|
||||
event_id: owned_event_id!("$ev0"),
|
||||
};
|
||||
|
||||
// The `LatestEventValue` hasn't changed, it still matches the latest local
|
||||
@@ -3023,7 +3023,7 @@ mod builder_tests {
|
||||
{
|
||||
let new_content = SerializableEventContent::new(&AnyMessageLikeEventContent::Reaction(
|
||||
ReactionEventContent::new(Annotation::new(
|
||||
event_id!("$ev0").to_owned(),
|
||||
owned_event_id!("$ev0"),
|
||||
"+1".to_owned(),
|
||||
)),
|
||||
))
|
||||
@@ -3192,7 +3192,7 @@ mod builder_tests {
|
||||
{
|
||||
let update = RoomSendQueueUpdate::SentEvent {
|
||||
transaction_id: transaction_id_0.clone(),
|
||||
event_id: event_id!("$ev0").to_owned(),
|
||||
event_id: owned_event_id!("$ev0"),
|
||||
};
|
||||
|
||||
// The `LatestEventValue` has changed, it still matches the latest local
|
||||
@@ -3270,7 +3270,7 @@ mod builder_tests {
|
||||
{
|
||||
let update = RoomSendQueueUpdate::SentEvent {
|
||||
transaction_id: transaction_id_0.clone(),
|
||||
event_id: event_id!("$ev0").to_owned(),
|
||||
event_id: owned_event_id!("$ev0"),
|
||||
};
|
||||
|
||||
// The `LatestEventValue` has changed, it still matches the latest local
|
||||
|
||||
@@ -316,7 +316,7 @@ mod tests_latest_event {
|
||||
use ruma::{
|
||||
MilliSecondsSinceUnixEpoch, OwnedTransactionId, event_id,
|
||||
events::{AnyMessageLikeEventContent, room::message::RoomMessageEventContent},
|
||||
room_id, user_id,
|
||||
owned_event_id, owned_room_id, room_id, user_id,
|
||||
};
|
||||
use stream_assert::{assert_next_matches, assert_pending};
|
||||
|
||||
@@ -472,7 +472,7 @@ mod tests_latest_event {
|
||||
|
||||
#[async_test]
|
||||
async fn test_local_has_priority_over_remote() {
|
||||
let room_id = room_id!("!r0").to_owned();
|
||||
let room_id = owned_room_id!("!r0");
|
||||
let user_id = user_id!("@mnt_io:matrix.org");
|
||||
let event_factory = EventFactory::new().sender(user_id).room(&room_id);
|
||||
|
||||
@@ -561,7 +561,7 @@ mod tests_latest_event {
|
||||
{
|
||||
let update = RoomSendQueueUpdate::SentEvent {
|
||||
transaction_id,
|
||||
event_id: event_id!("$ev1").to_owned(),
|
||||
event_id: owned_event_id!("$ev1"),
|
||||
};
|
||||
|
||||
latest_event.update_with_send_queue(&update, &room_event_cache, user_id, None).await;
|
||||
@@ -583,7 +583,7 @@ mod tests_latest_event {
|
||||
|
||||
#[async_test]
|
||||
async fn test_store_latest_event_value() {
|
||||
let room_id = room_id!("!r0").to_owned();
|
||||
let room_id = owned_room_id!("!r0");
|
||||
let user_id = user_id!("@mnt_io:matrix.org");
|
||||
let event_factory = EventFactory::new().sender(user_id).room(&room_id);
|
||||
|
||||
|
||||
@@ -680,7 +680,7 @@ mod tests {
|
||||
AnySyncMessageLikeEvent, AnySyncStateEvent, AnySyncTimelineEvent, SyncMessageLikeEvent,
|
||||
room::member::{MembershipState, SyncRoomMemberEvent},
|
||||
},
|
||||
owned_room_id, room_id, user_id,
|
||||
owned_event_id, owned_room_id, room_id, user_id,
|
||||
};
|
||||
use stream_assert::assert_pending;
|
||||
use tokio::{task::yield_now, time::timeout};
|
||||
@@ -946,7 +946,7 @@ mod tests {
|
||||
room_id: room_id.clone(),
|
||||
update: RoomSendQueueUpdate::SentEvent {
|
||||
transaction_id: OwnedTransactionId::from("txnid0"),
|
||||
event_id: event_id!("$ev0").to_owned(),
|
||||
event_id: owned_event_id!("$ev0"),
|
||||
},
|
||||
})
|
||||
.unwrap();
|
||||
@@ -979,7 +979,7 @@ mod tests {
|
||||
room_id: room_id.clone(),
|
||||
update: RoomSendQueueUpdate::SentEvent {
|
||||
transaction_id: OwnedTransactionId::from("txnid1"),
|
||||
event_id: event_id!("$ev1").to_owned(),
|
||||
event_id: owned_event_id!("$ev1"),
|
||||
},
|
||||
})
|
||||
.unwrap();
|
||||
|
||||
@@ -896,10 +896,11 @@ impl MatrixMockServer {
|
||||
/// use std::collections::BTreeMap;
|
||||
/// use matrix_sdk::{
|
||||
/// ruma::{
|
||||
/// events::{AnyToDeviceEventContent, dummy::ToDeviceDummyEventContent},
|
||||
/// serde::Raw,
|
||||
/// api::client::to_device::send_event_to_device::v3::Request as ToDeviceRequest,
|
||||
/// to_device::DeviceIdOrAllDevices,
|
||||
/// user_id,owned_device_id
|
||||
/// owned_user_id, owned_device_id
|
||||
/// },
|
||||
/// test_utils::mocks::MatrixMockServer,
|
||||
/// };
|
||||
@@ -913,12 +914,13 @@ impl MatrixMockServer {
|
||||
/// let request = ToDeviceRequest::new_raw(
|
||||
/// "m.custom.event".into(),
|
||||
/// "txn_id".into(),
|
||||
/// BTreeMap::from([
|
||||
/// (user_id!("@alice:localhost").to_owned(), BTreeMap::from([(
|
||||
/// DeviceIdOrAllDevices::AllDevices,
|
||||
/// Raw::new(&ruma::events::AnyToDeviceEventContent::Dummy(ruma::events::dummy::ToDeviceDummyEventContent {})).unwrap(),
|
||||
/// )])),
|
||||
/// ])
|
||||
/// BTreeMap::from([(
|
||||
/// owned_user_id!("@alice:localhost"),
|
||||
/// BTreeMap::from([(
|
||||
/// DeviceIdOrAllDevices::AllDevices,
|
||||
/// Raw::new(&AnyToDeviceEventContent::Dummy(ToDeviceDummyEventContent {})).unwrap(),
|
||||
/// )])
|
||||
/// )]),
|
||||
/// );
|
||||
///
|
||||
/// client
|
||||
|
||||
@@ -41,7 +41,7 @@ use ruma::{
|
||||
},
|
||||
uiaa,
|
||||
},
|
||||
assign, device_id,
|
||||
assign,
|
||||
directory::Filter,
|
||||
event_id,
|
||||
events::{
|
||||
@@ -53,7 +53,7 @@ use ruma::{
|
||||
},
|
||||
tag::{TagInfo, TagName, Tags},
|
||||
},
|
||||
owned_event_id, owned_room_id,
|
||||
owned_device_id, owned_event_id, owned_room_id, owned_user_id,
|
||||
room::JoinRule,
|
||||
room_id,
|
||||
serde::Raw,
|
||||
@@ -135,7 +135,7 @@ async fn test_delete_devices() {
|
||||
.mount(&server)
|
||||
.await;
|
||||
|
||||
let devices = &[device_id!("DEVICEID").to_owned()];
|
||||
let devices = &[owned_device_id!("DEVICEID")];
|
||||
|
||||
if let Err(e) = client.delete_devices(devices, None).await
|
||||
&& let Some(info) = e.as_uiaa_response()
|
||||
@@ -1489,11 +1489,8 @@ async fn test_room_sync_state_after() {
|
||||
f.create(user_id!("@example:localhost"), RoomVersionId::V1).into(),
|
||||
{
|
||||
let mut users = BTreeMap::new();
|
||||
users.insert(
|
||||
user_id!("@example:localhost").to_owned(),
|
||||
Int::new(100).unwrap(),
|
||||
);
|
||||
users.insert(user_id!("@bob:localhost").to_owned(), Int::new(0).unwrap());
|
||||
users.insert(owned_user_id!("@example:localhost"), Int::new(100).unwrap());
|
||||
users.insert(owned_user_id!("@bob:localhost"), Int::new(0).unwrap());
|
||||
f.power_levels(&mut users).into()
|
||||
},
|
||||
f.room_history_visibility(HistoryVisibility::WorldReadable).into(),
|
||||
|
||||
@@ -41,7 +41,7 @@ use matrix_sdk_test::{JoinedRoomBuilder, SyncResponseBuilder, TestResult, async_
|
||||
use ruma::{
|
||||
EventId, RoomId, TransactionId,
|
||||
api::client::room::create_room::v3::Request as CreateRoomRequest,
|
||||
assign, device_id, event_id,
|
||||
assign, event_id,
|
||||
events::room::message::{RoomMessageEvent, RoomMessageEventContent},
|
||||
owned_device_id, owned_user_id, room_id, user_id,
|
||||
};
|
||||
@@ -1418,7 +1418,7 @@ async fn test_enable_from_secret_storage_and_download_after_utd_from_old_message
|
||||
curve25519: Curve25519PublicKey::from(&Curve25519SecretKey::new()),
|
||||
};
|
||||
let outbound_group_session = OutboundGroupSession::new(
|
||||
device_id!("KIUVQQSDTM").to_owned(),
|
||||
owned_device_id!("KIUVQQSDTM"),
|
||||
Arc::new(sender_identity_keys),
|
||||
room_id,
|
||||
matrix_sdk_base::crypto::EncryptionSettings::default(),
|
||||
|
||||
@@ -32,7 +32,7 @@ use matrix_sdk::{
|
||||
};
|
||||
use matrix_sdk_base::SessionMeta;
|
||||
use matrix_sdk_test::async_test;
|
||||
use ruma::{UserId, api::client::uiaa, device_id, user_id};
|
||||
use ruma::{UserId, api::client::uiaa, owned_device_id, user_id};
|
||||
use serde::Deserialize;
|
||||
use serde_json::{Value, json};
|
||||
use tokio::spawn;
|
||||
@@ -45,7 +45,7 @@ use crate::{encryption::mock_secret_store_with_backup_key, logged_in_client_with
|
||||
|
||||
async fn test_client(user_id: &UserId) -> (Client, wiremock::MockServer) {
|
||||
let session = MatrixSession {
|
||||
meta: SessionMeta { user_id: user_id.into(), device_id: device_id!("DEVICEID").to_owned() },
|
||||
meta: SessionMeta { user_id: user_id.into(), device_id: owned_device_id!("DEVICEID") },
|
||||
tokens: mock_session_tokens(),
|
||||
};
|
||||
|
||||
@@ -170,7 +170,7 @@ async fn test_recovery_status_secret_storage_set_up() {
|
||||
let user_id = user_id!("@example:morpheus.localhost");
|
||||
|
||||
let session = MatrixSession {
|
||||
meta: SessionMeta { user_id: user_id.into(), device_id: device_id!("DEVICEID").to_owned() },
|
||||
meta: SessionMeta { user_id: user_id.into(), device_id: owned_device_id!("DEVICEID") },
|
||||
tokens: mock_session_tokens(),
|
||||
};
|
||||
|
||||
@@ -191,7 +191,7 @@ async fn test_recovery_status_secret_storage_not_set_up() {
|
||||
let user_id = user_id!("@example:morpheus.localhost");
|
||||
|
||||
let session = MatrixSession {
|
||||
meta: SessionMeta { user_id: user_id.into(), device_id: device_id!("DEVICEID").to_owned() },
|
||||
meta: SessionMeta { user_id: user_id.into(), device_id: owned_device_id!("DEVICEID") },
|
||||
tokens: mock_session_tokens(),
|
||||
};
|
||||
|
||||
@@ -719,7 +719,7 @@ async fn test_recover_and_reset() {
|
||||
const KEY_ID: &str = "yJWwBm2Ts8jHygTBslKpABFyykavhhfA";
|
||||
|
||||
let session = MatrixSession {
|
||||
meta: SessionMeta { user_id: user_id.into(), device_id: device_id!("DEVICEID").to_owned() },
|
||||
meta: SessionMeta { user_id: user_id.into(), device_id: owned_device_id!("DEVICEID") },
|
||||
tokens: mock_session_tokens(),
|
||||
};
|
||||
|
||||
|
||||
@@ -9,14 +9,14 @@ use matrix_sdk::{
|
||||
use matrix_sdk_base::SessionMeta;
|
||||
use matrix_sdk_test::async_test;
|
||||
use ruma::{
|
||||
UserId, device_id,
|
||||
UserId,
|
||||
events::{
|
||||
secret::request::SecretName,
|
||||
secret_storage::{
|
||||
default_key::SecretStorageDefaultKeyEventContent, secret::SecretEventContent,
|
||||
},
|
||||
},
|
||||
user_id,
|
||||
owned_device_id, owned_user_id, user_id,
|
||||
};
|
||||
use serde_json::json;
|
||||
use wiremock::{
|
||||
@@ -371,8 +371,8 @@ async fn test_restore_cross_signing_from_secret_store() {
|
||||
|
||||
let session = MatrixSession {
|
||||
meta: SessionMeta {
|
||||
user_id: user_id!("@example:morpheus.localhost").to_owned(),
|
||||
device_id: device_id!("DEVICEID").to_owned(),
|
||||
user_id: owned_user_id!("@example:morpheus.localhost"),
|
||||
device_id: owned_device_id!("DEVICEID"),
|
||||
},
|
||||
tokens: mock_session_tokens(),
|
||||
};
|
||||
@@ -572,8 +572,8 @@ async fn test_is_secret_storage_enabled() {
|
||||
|
||||
let session = MatrixSession {
|
||||
meta: SessionMeta {
|
||||
user_id: user_id!("@example:morpheus.localhost").to_owned(),
|
||||
device_id: device_id!("DEVICEID").to_owned(),
|
||||
user_id: owned_user_id!("@example:morpheus.localhost"),
|
||||
device_id: owned_device_id!("DEVICEID"),
|
||||
},
|
||||
tokens: mock_session_tokens(),
|
||||
};
|
||||
|
||||
@@ -5,12 +5,12 @@ use matrix_sdk::{
|
||||
test_utils::mocks::MatrixMockServer,
|
||||
};
|
||||
use matrix_sdk_test::{async_test, event_factory::EventFactory};
|
||||
use ruma::{event_id, room_id, user_id};
|
||||
use ruma::{event_id, owned_room_id, user_id};
|
||||
use tokio::task::yield_now;
|
||||
|
||||
#[async_test]
|
||||
async fn test_latest_event_is_recomputed_when_a_user_is_ignored() {
|
||||
let room_id = room_id!("!r0").to_owned();
|
||||
let room_id = owned_room_id!("!r0");
|
||||
let alice = user_id!("@alice:local");
|
||||
let bob = user_id!("@bob:local");
|
||||
let event_alice = event_id!("$ev0");
|
||||
|
||||
@@ -22,8 +22,9 @@ use ruma::{
|
||||
uiaa::{self, AuthData, UserIdentifier},
|
||||
},
|
||||
},
|
||||
assign, device_id,
|
||||
assign,
|
||||
encryption::CrossSigningKey,
|
||||
owned_device_id, owned_user_id,
|
||||
serde::Raw,
|
||||
user_id,
|
||||
};
|
||||
@@ -333,8 +334,8 @@ fn test_serialize_session() {
|
||||
// Without refresh token.
|
||||
let mut session = MatrixSession {
|
||||
meta: SessionMeta {
|
||||
user_id: user_id!("@user:localhost").to_owned(),
|
||||
device_id: device_id!("EFGHIJ").to_owned(),
|
||||
user_id: owned_user_id!("@user:localhost"),
|
||||
device_id: owned_device_id!("EFGHIJ"),
|
||||
},
|
||||
tokens: SessionTokens { access_token: "abcd".to_owned(), refresh_token: None },
|
||||
};
|
||||
|
||||
@@ -7,7 +7,7 @@ use ruma::{
|
||||
api::client::media::get_content_thumbnail::v3::Method,
|
||||
assign,
|
||||
events::room::{ImageInfo, MediaSource, message::ImageMessageEventContent},
|
||||
mxc_uri, owned_mxc_uri, uint,
|
||||
owned_mxc_uri, uint,
|
||||
};
|
||||
|
||||
#[async_test]
|
||||
@@ -27,7 +27,7 @@ async fn test_get_media_content_no_auth() {
|
||||
let media = client.media();
|
||||
|
||||
let request = MediaRequestParameters {
|
||||
source: MediaSource::Plain(mxc_uri!("mxc://localhost/textfile").to_owned()),
|
||||
source: MediaSource::Plain(owned_mxc_uri!("mxc://localhost/textfile")),
|
||||
format: MediaFormat::File,
|
||||
};
|
||||
|
||||
@@ -102,7 +102,7 @@ async fn test_get_media_file_no_auth() {
|
||||
|
||||
let event_content = ImageMessageEventContent::plain(
|
||||
"filename.jpg".into(),
|
||||
mxc_uri!("mxc://example.org/image").to_owned(),
|
||||
owned_mxc_uri!("mxc://example.org/image"),
|
||||
)
|
||||
.info(Box::new(assign!(ImageInfo::new(), {
|
||||
height: Some(uint!(398)),
|
||||
@@ -171,7 +171,7 @@ async fn test_get_media_file_with_auth_matrix_1_11() {
|
||||
// Build event content.
|
||||
let event_content = ImageMessageEventContent::plain(
|
||||
"filename.jpg".into(),
|
||||
mxc_uri!("mxc://example.org/image").to_owned(),
|
||||
owned_mxc_uri!("mxc://example.org/image"),
|
||||
)
|
||||
.info(Box::new(assign!(ImageInfo::new(), {
|
||||
height: Some(uint!(398)),
|
||||
@@ -243,7 +243,7 @@ async fn test_get_media_file_with_auth_matrix_stable_feature() {
|
||||
// Build event content.
|
||||
let event_content = ImageMessageEventContent::plain(
|
||||
"filename.jpg".into(),
|
||||
mxc_uri!("mxc://example.org/image").to_owned(),
|
||||
owned_mxc_uri!("mxc://example.org/image"),
|
||||
)
|
||||
.info(Box::new(assign!(ImageInfo::new(), {
|
||||
height: Some(uint!(398)),
|
||||
|
||||
@@ -13,7 +13,7 @@ use matrix_sdk_test::{
|
||||
use ruma::{
|
||||
Int, OwnedRoomId, event_id,
|
||||
events::{AnyStrippedStateEvent, StateEventType},
|
||||
room_id,
|
||||
owned_user_id, room_id,
|
||||
serde::Raw,
|
||||
user_id,
|
||||
};
|
||||
@@ -45,8 +45,8 @@ async fn test_notifications_joined() {
|
||||
let mut sync_builder = SyncResponseBuilder::new();
|
||||
let f = EventFactory::new().room(room_id).sender(user_id!("@example:localhost"));
|
||||
let mut users = BTreeMap::new();
|
||||
users.insert(user_id!("@example:localhost").to_owned(), Int::new(100).unwrap());
|
||||
users.insert(user_id!("@bob:localhost").to_owned(), Int::new(0).unwrap());
|
||||
users.insert(owned_user_id!("@example:localhost"), Int::new(100).unwrap());
|
||||
users.insert(owned_user_id!("@bob:localhost"), Int::new(0).unwrap());
|
||||
let joined_room = JoinedRoomBuilder::new(room_id).add_state_bulk([
|
||||
f.power_levels(&mut users).into_raw_sync_state(),
|
||||
sync_state_event!({
|
||||
@@ -125,8 +125,8 @@ async fn test_notifications_invite() {
|
||||
let mut sync_builder = SyncResponseBuilder::new();
|
||||
let f = EventFactory::new().room(room_id).sender(user_id!("@example:localhost"));
|
||||
let mut users = BTreeMap::new();
|
||||
users.insert(user_id!("@example:localhost").to_owned(), Int::new(100).unwrap());
|
||||
users.insert(user_id!("@bob:localhost").to_owned(), Int::new(0).unwrap());
|
||||
users.insert(owned_user_id!("@example:localhost"), Int::new(100).unwrap());
|
||||
users.insert(owned_user_id!("@bob:localhost"), Int::new(0).unwrap());
|
||||
let power_levels_event: Raw<AnyStrippedStateEvent> = f.power_levels(&mut users).into();
|
||||
let invited_room = InvitedRoomBuilder::new(room_id).add_state_bulk([
|
||||
power_levels_event,
|
||||
|
||||
@@ -37,7 +37,7 @@ use ruma::{
|
||||
message::{RoomMessageEventContent, RoomMessageEventContentWithoutRelation},
|
||||
},
|
||||
},
|
||||
int, mxc_uri, owned_event_id, room_id, thirdparty, user_id,
|
||||
int, mxc_uri, owned_event_id, owned_user_id, room_id, thirdparty, user_id,
|
||||
};
|
||||
use serde_json::json;
|
||||
use stream_assert::assert_pending;
|
||||
@@ -1423,7 +1423,7 @@ async fn test_room_member_updates_sender_on_partial_members_update() {
|
||||
// members
|
||||
let next = assert_recv_with_timeout!(receiver, 100);
|
||||
assert_let!(RoomMembersUpdate::Partial(user_ids) = next);
|
||||
assert_eq!(user_ids, BTreeSet::from_iter(vec![user_id!("@alice:b.c").to_owned()]));
|
||||
assert_eq!(user_ids, BTreeSet::from_iter(vec![owned_user_id!("@alice:b.c")]));
|
||||
}
|
||||
|
||||
#[async_test]
|
||||
|
||||
@@ -8,6 +8,7 @@ use ruma::{
|
||||
api::client::keys::get_keys::v3::Response as KeyQueryResponse,
|
||||
device_id,
|
||||
encryption::{CrossSigningKey, DeviceKeys, KeyUsage},
|
||||
owned_device_id,
|
||||
serde::Raw,
|
||||
user_id,
|
||||
};
|
||||
@@ -840,7 +841,7 @@ impl VerificationViolationTestData {
|
||||
"device_display_name": "Element - dbg Android"
|
||||
}
|
||||
});
|
||||
(device_id!("AHIVRZICJK").to_owned(), serde_json::from_value(json).unwrap())
|
||||
(owned_device_id!("AHIVRZICJK"), serde_json::from_value(json).unwrap())
|
||||
}
|
||||
|
||||
/// Device ID of the device returned by [`Self::own_signed_device_keys`].
|
||||
@@ -876,7 +877,7 @@ impl VerificationViolationTestData {
|
||||
"device_display_name": "develop.element.io: Chrome on macOS"
|
||||
}
|
||||
});
|
||||
(device_id!("LCNRWQAVWK").to_owned(), serde_json::from_value(json).unwrap())
|
||||
(owned_device_id!("LCNRWQAVWK"), serde_json::from_value(json).unwrap())
|
||||
}
|
||||
|
||||
/// `/keys/query` response for Bob, signed by Alice's identity.
|
||||
|
||||
Reference in New Issue
Block a user