Merge branch 'master' into sas-verification
commit
2bf8c99dfe
|
@ -1,5 +1,4 @@
|
|||
use std::convert::TryFrom;
|
||||
use std::{env, process::exit};
|
||||
use std::{convert::TryFrom, env, process::exit};
|
||||
|
||||
use url::Url;
|
||||
|
||||
|
|
|
@ -15,19 +15,23 @@
|
|||
|
||||
#[cfg(feature = "encryption")]
|
||||
use std::collections::BTreeMap;
|
||||
use std::collections::HashMap;
|
||||
use std::convert::{TryFrom, TryInto};
|
||||
use std::fmt::{self, Debug};
|
||||
use std::path::Path;
|
||||
use std::result::Result as StdResult;
|
||||
use std::sync::Arc;
|
||||
use std::{
|
||||
collections::HashMap,
|
||||
convert::{TryFrom, TryInto},
|
||||
fmt::{self, Debug},
|
||||
path::Path,
|
||||
result::Result as StdResult,
|
||||
sync::Arc,
|
||||
};
|
||||
|
||||
use matrix_sdk_common::identifiers::ServerName;
|
||||
use matrix_sdk_common::instant::{Duration, Instant};
|
||||
use matrix_sdk_common::js_int::UInt;
|
||||
use matrix_sdk_common::locks::RwLock;
|
||||
use matrix_sdk_common::presence::PresenceState;
|
||||
use matrix_sdk_common::uuid::Uuid;
|
||||
use matrix_sdk_common::{
|
||||
identifiers::ServerName,
|
||||
instant::{Duration, Instant},
|
||||
js_int::UInt,
|
||||
locks::RwLock,
|
||||
presence::PresenceState,
|
||||
uuid::Uuid,
|
||||
};
|
||||
|
||||
use futures_timer::Delay as sleep;
|
||||
use std::future::Future;
|
||||
|
@ -38,22 +42,18 @@ use tracing::{error, info, instrument};
|
|||
use reqwest::header::{HeaderValue, InvalidHeaderValue};
|
||||
use url::Url;
|
||||
|
||||
use crate::events::room::message::MessageEventContent;
|
||||
use crate::events::EventType;
|
||||
use crate::identifiers::{EventId, RoomId, RoomIdOrAliasId, UserId};
|
||||
use crate::Endpoint;
|
||||
use crate::{
|
||||
events::{room::message::MessageEventContent, EventType},
|
||||
identifiers::{EventId, RoomId, RoomIdOrAliasId, UserId},
|
||||
Endpoint,
|
||||
};
|
||||
|
||||
#[cfg(feature = "encryption")]
|
||||
use crate::identifiers::DeviceId;
|
||||
|
||||
#[cfg(feature = "encryption")]
|
||||
use crate::Sas;
|
||||
|
||||
use crate::api;
|
||||
use crate::http_client::HttpClient;
|
||||
#[cfg(not(target_arch = "wasm32"))]
|
||||
use crate::VERSION;
|
||||
use crate::{EventEmitter, Result};
|
||||
use crate::{api, http_client::HttpClient, sas::Sas, EventEmitter, Result};
|
||||
use matrix_sdk_base::{BaseClient, BaseClientConfig, Room, Session, StateStore};
|
||||
|
||||
const DEFAULT_SYNC_TIMEOUT: Duration = Duration::from_secs(30);
|
||||
|
@ -271,27 +271,27 @@ impl SyncSettings {
|
|||
}
|
||||
}
|
||||
|
||||
use api::r0::account::register;
|
||||
use api::r0::directory::get_public_rooms;
|
||||
use api::r0::directory::get_public_rooms_filtered;
|
||||
#[cfg(feature = "encryption")]
|
||||
use api::r0::keys::{claim_keys, get_keys, upload_keys, KeyAlgorithm};
|
||||
use api::r0::membership::{
|
||||
ban_user, forget_room,
|
||||
invite_user::{self, InvitationRecipient},
|
||||
join_room_by_id, join_room_by_id_or_alias, kick_user, leave_room, Invite3pid,
|
||||
};
|
||||
use api::r0::message::create_message_event;
|
||||
use api::r0::message::get_message_events;
|
||||
use api::r0::read_marker::set_read_marker;
|
||||
use api::r0::receipt::create_receipt;
|
||||
use api::r0::room::create_room;
|
||||
use api::r0::session::login;
|
||||
use api::r0::sync::sync_events;
|
||||
#[cfg(feature = "encryption")]
|
||||
use api::r0::to_device::send_event_to_device;
|
||||
use api::r0::typing::create_typing_event;
|
||||
use api::r0::uiaa::UiaaResponse;
|
||||
use api::r0::{
|
||||
account::register,
|
||||
directory::{get_public_rooms, get_public_rooms_filtered},
|
||||
membership::{
|
||||
ban_user, forget_room,
|
||||
invite_user::{self, InvitationRecipient},
|
||||
join_room_by_id, join_room_by_id_or_alias, kick_user, leave_room, Invite3pid,
|
||||
},
|
||||
message::{create_message_event, get_message_events},
|
||||
read_marker::set_read_marker,
|
||||
receipt::create_receipt,
|
||||
room::create_room,
|
||||
session::login,
|
||||
sync::sync_events,
|
||||
typing::create_typing_event,
|
||||
uiaa::UiaaResponse,
|
||||
};
|
||||
|
||||
impl Client {
|
||||
/// Creates a new client for making HTTP requests to the given homeserver.
|
||||
|
@ -315,10 +315,10 @@ impl Client {
|
|||
homeserver_url: U,
|
||||
config: ClientConfig,
|
||||
) -> Result<Self> {
|
||||
#[allow(clippy::match_wild_err_arm)]
|
||||
let homeserver: Url = match homeserver_url.try_into() {
|
||||
Ok(u) => u,
|
||||
Err(_e) => panic!("Error parsing homeserver url"),
|
||||
let homeserver = if let Ok(u) = homeserver_url.try_into() {
|
||||
u
|
||||
} else {
|
||||
panic!("Error parsing homeserver url")
|
||||
};
|
||||
|
||||
let http_client = reqwest::Client::builder();
|
||||
|
@ -1473,23 +1473,27 @@ mod test {
|
|||
get_public_rooms_filtered::{self, Filter},
|
||||
invite_user, kick_user, leave_room,
|
||||
register::RegistrationKind,
|
||||
set_read_marker, Invite3pid, MessageEventContent,
|
||||
set_read_marker, Client, ClientConfig, Invite3pid, MessageEventContent, Session,
|
||||
SyncSettings, Url,
|
||||
};
|
||||
use super::{Client, ClientConfig, Session, SyncSettings, Url};
|
||||
use crate::events::room::message::TextMessageEventContent;
|
||||
|
||||
use crate::identifiers::{EventId, RoomId, RoomIdOrAliasId, UserId};
|
||||
use crate::{RegistrationBuilder, RoomListFilterBuilder};
|
||||
use crate::{
|
||||
identifiers::{EventId, RoomId, RoomIdOrAliasId, UserId},
|
||||
RegistrationBuilder, RoomListFilterBuilder,
|
||||
};
|
||||
|
||||
use matrix_sdk_base::JsonStore;
|
||||
use matrix_sdk_test::{test_json, EventBuilder, EventsJson};
|
||||
use mockito::{mock, Matcher};
|
||||
use tempfile::tempdir;
|
||||
|
||||
use std::convert::{TryFrom, TryInto};
|
||||
use std::path::Path;
|
||||
use std::str::FromStr;
|
||||
use std::time::Duration;
|
||||
use std::{
|
||||
convert::{TryFrom, TryInto},
|
||||
path::Path,
|
||||
str::FromStr,
|
||||
time::Duration,
|
||||
};
|
||||
|
||||
#[tokio::test]
|
||||
async fn test_join_leave_room() {
|
||||
|
@ -2395,6 +2399,26 @@ mod test {
|
|||
assert!(logged_in, "Clint should be logged in");
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn login_with_device() {
|
||||
let homeserver = Url::from_str(&mockito::server_url()).unwrap();
|
||||
|
||||
let _m = mock("POST", "/_matrix/client/r0/login")
|
||||
.with_status(200)
|
||||
.with_body(test_json::LOGIN.to_string())
|
||||
.create();
|
||||
|
||||
let client = Client::new(homeserver).unwrap();
|
||||
|
||||
client
|
||||
.login("example", "wordpass", None, None)
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
let logged_in = client.logged_in().await;
|
||||
assert!(logged_in, "Clint should be logged in");
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn sync() {
|
||||
let homeserver = Url::from_str(&mockito::server_url()).unwrap();
|
||||
|
|
|
@ -14,18 +14,17 @@
|
|||
|
||||
//! Error conditions.
|
||||
|
||||
use matrix_sdk_base::Error as MatrixError;
|
||||
use matrix_sdk_common::{
|
||||
api::{r0::uiaa::UiaaResponse as UiaaError, Error as RumaClientError},
|
||||
FromHttpResponseError as RumaResponseError, IntoHttpError as RumaIntoHttpError,
|
||||
};
|
||||
use reqwest::Error as ReqwestError;
|
||||
use serde_json::Error as JsonError;
|
||||
use thiserror::Error;
|
||||
|
||||
#[cfg(feature = "encryption")]
|
||||
use matrix_sdk_base::CryptoStoreError;
|
||||
use matrix_sdk_base::Error as MatrixError;
|
||||
|
||||
use crate::api::r0::uiaa::UiaaResponse as UiaaError;
|
||||
use crate::api::Error as RumaClientError;
|
||||
use crate::FromHttpResponseError as RumaResponseError;
|
||||
use crate::IntoHttpError as RumaIntoHttpError;
|
||||
|
||||
/// Result type of the rust-sdk.
|
||||
pub type Result<T> = std::result::Result<T, Error>;
|
||||
|
|
|
@ -12,8 +12,7 @@
|
|||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
use std::convert::TryFrom;
|
||||
use std::sync::Arc;
|
||||
use std::{convert::TryFrom, sync::Arc};
|
||||
|
||||
use http::{Method as HttpMethod, Response as HttpResponse};
|
||||
use reqwest::{header::AUTHORIZATION, Client, Response};
|
||||
|
|
|
@ -36,24 +36,23 @@
|
|||
unused_qualifications
|
||||
)]
|
||||
|
||||
pub use matrix_sdk_base::Error as BaseError;
|
||||
#[cfg(not(target_arch = "wasm32"))]
|
||||
pub use matrix_sdk_base::JsonStore;
|
||||
pub use matrix_sdk_base::{CustomOrRawEvent, EventEmitter, Room, Session, SyncRoom};
|
||||
#[cfg(feature = "messages")]
|
||||
pub use matrix_sdk_base::{MessageQueue, PossiblyRedactedExt};
|
||||
pub use matrix_sdk_base::{RoomState, StateStore};
|
||||
pub use matrix_sdk_common::*;
|
||||
pub use reqwest::header::InvalidHeaderValue;
|
||||
|
||||
pub use matrix_sdk_base::{
|
||||
CustomOrRawEvent, Error as BaseError, EventEmitter, Room, RoomState, Session, StateStore,
|
||||
SyncRoom,
|
||||
};
|
||||
#[cfg(feature = "encryption")]
|
||||
pub use matrix_sdk_base::{Device, TrustState};
|
||||
#[cfg(feature = "messages")]
|
||||
pub use matrix_sdk_base::{MessageQueue, PossiblyRedactedExt};
|
||||
pub use matrix_sdk_common::*;
|
||||
pub use reqwest::header::InvalidHeaderValue;
|
||||
|
||||
mod client;
|
||||
mod error;
|
||||
mod http_client;
|
||||
mod request_builder;
|
||||
#[cfg(feature = "encryption")]
|
||||
mod sas;
|
||||
|
||||
pub use client::{Client, ClientConfig, SyncSettings};
|
||||
|
|
|
@ -454,10 +454,13 @@ mod test {
|
|||
use std::collections::BTreeMap;
|
||||
|
||||
use super::*;
|
||||
use crate::api::r0::filter::{LazyLoadOptions, RoomEventFilter};
|
||||
use crate::events::room::power_levels::NotificationPowerLevels;
|
||||
use crate::js_int::Int;
|
||||
use crate::{identifiers::RoomId, Client, Session};
|
||||
use crate::{
|
||||
api::r0::filter::{LazyLoadOptions, RoomEventFilter},
|
||||
events::room::power_levels::NotificationPowerLevels,
|
||||
identifiers::RoomId,
|
||||
js_int::Int,
|
||||
Client, Session,
|
||||
};
|
||||
|
||||
use matrix_sdk_test::test_json;
|
||||
use mockito::{mock, Matcher};
|
||||
|
|
|
@ -13,58 +13,59 @@
|
|||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
use std::collections::HashMap;
|
||||
#[cfg(feature = "encryption")]
|
||||
use std::collections::{BTreeMap, HashSet};
|
||||
use std::fmt;
|
||||
use std::path::{Path, PathBuf};
|
||||
use std::sync::Arc;
|
||||
use zeroize::Zeroizing;
|
||||
|
||||
use std::result::Result as StdResult;
|
||||
|
||||
use crate::api::r0 as api;
|
||||
use crate::error::Result;
|
||||
use crate::events::presence::PresenceEvent;
|
||||
// `NonRoomEvent` is what it is aliased as
|
||||
use crate::event_emitter::CustomOrRawEvent;
|
||||
use crate::events::ignored_user_list::IgnoredUserListEvent;
|
||||
use crate::events::push_rules::PushRulesEvent;
|
||||
use crate::events::room::member::MemberEventContent;
|
||||
use crate::identifiers::{RoomId, UserId};
|
||||
use crate::models::Room;
|
||||
use crate::push::Ruleset;
|
||||
use crate::session::Session;
|
||||
use crate::state::{AllRooms, ClientState, StateStore};
|
||||
use crate::EventEmitter;
|
||||
use matrix_sdk_common::events::{
|
||||
AnyBasicEvent, AnyStrippedStateEvent, AnySyncEphemeralRoomEvent, AnySyncMessageEvent,
|
||||
AnySyncRoomEvent, AnySyncStateEvent,
|
||||
use std::{
|
||||
collections::HashMap,
|
||||
fmt,
|
||||
ops::Deref,
|
||||
path::{Path, PathBuf},
|
||||
result::Result as StdResult,
|
||||
sync::Arc,
|
||||
};
|
||||
use matrix_sdk_common::Raw;
|
||||
|
||||
#[cfg(feature = "encryption")]
|
||||
use matrix_sdk_common::locks::Mutex;
|
||||
use matrix_sdk_common::locks::RwLock;
|
||||
use std::ops::Deref;
|
||||
|
||||
#[cfg(feature = "encryption")]
|
||||
use crate::api::r0::keys::{
|
||||
claim_keys::Response as KeysClaimResponse, get_keys::Response as KeysQueryResponse,
|
||||
upload_keys::Response as KeysUploadResponse, DeviceKeys, KeyAlgorithm,
|
||||
use matrix_sdk_common::{
|
||||
api::r0 as api,
|
||||
events::{
|
||||
ignored_user_list::IgnoredUserListEvent, push_rules::PushRulesEvent,
|
||||
room::member::MemberEventContent, AnyBasicEvent, AnyStrippedStateEvent,
|
||||
AnySyncEphemeralRoomEvent, AnySyncMessageEvent, AnySyncRoomEvent, AnySyncStateEvent,
|
||||
},
|
||||
identifiers::{RoomId, UserId},
|
||||
locks::RwLock,
|
||||
push::Ruleset,
|
||||
Raw,
|
||||
};
|
||||
#[cfg(feature = "encryption")]
|
||||
use crate::api::r0::to_device::send_event_to_device::Request as ToDeviceRequest;
|
||||
#[cfg(feature = "encryption")]
|
||||
use crate::events::room::{
|
||||
encrypted::EncryptedEventContent, message::MessageEventContent as MsgEventContent,
|
||||
use matrix_sdk_common::{
|
||||
api::r0::keys::{
|
||||
claim_keys::Response as KeysClaimResponse, get_keys::Response as KeysQueryResponse,
|
||||
upload_keys::Response as KeysUploadResponse, DeviceKeys, KeyAlgorithm,
|
||||
},
|
||||
api::r0::to_device::send_event_to_device::Request as ToDeviceRequest,
|
||||
events::room::{
|
||||
encrypted::EncryptedEventContent, message::MessageEventContent as MsgEventContent,
|
||||
},
|
||||
identifiers::DeviceId,
|
||||
};
|
||||
#[cfg(feature = "encryption")]
|
||||
use crate::identifiers::DeviceId;
|
||||
#[cfg(not(target_arch = "wasm32"))]
|
||||
use crate::JsonStore;
|
||||
#[cfg(feature = "encryption")]
|
||||
use matrix_sdk_crypto::{CryptoStore, OlmError, OlmMachine, OneTimeKeys, Sas};
|
||||
use zeroize::Zeroizing;
|
||||
|
||||
#[cfg(not(target_arch = "wasm32"))]
|
||||
use crate::JsonStore;
|
||||
|
||||
use crate::{
|
||||
error::Result,
|
||||
event_emitter::CustomOrRawEvent,
|
||||
events::presence::PresenceEvent,
|
||||
models::Room,
|
||||
session::Session,
|
||||
state::{AllRooms, ClientState, StateStore},
|
||||
EventEmitter,
|
||||
};
|
||||
|
||||
pub type Token = String;
|
||||
|
||||
|
@ -1867,10 +1868,12 @@ impl BaseClient {
|
|||
|
||||
#[cfg(test)]
|
||||
mod test {
|
||||
use crate::identifiers::{RoomId, UserId};
|
||||
#[cfg(feature = "messages")]
|
||||
use crate::{events::AnySyncRoomEvent, identifiers::EventId, BaseClientConfig, JsonStore, Raw};
|
||||
use crate::{BaseClient, Session};
|
||||
use crate::{
|
||||
identifiers::{RoomId, UserId},
|
||||
BaseClient, Session,
|
||||
};
|
||||
use matrix_sdk_common_macros::async_trait;
|
||||
use matrix_sdk_test::{async_test, test_json, EventBuilder, EventsJson};
|
||||
use serde_json::json;
|
||||
|
@ -2033,11 +2036,13 @@ mod test {
|
|||
use super::*;
|
||||
|
||||
use crate::{EventEmitter, SyncRoom};
|
||||
use matrix_sdk_common::events::{
|
||||
room::member::{MemberEventContent, MembershipChange},
|
||||
SyncStateEvent,
|
||||
use matrix_sdk_common::{
|
||||
events::{
|
||||
room::member::{MemberEventContent, MembershipChange},
|
||||
SyncStateEvent,
|
||||
},
|
||||
locks::RwLock,
|
||||
};
|
||||
use matrix_sdk_common::locks::RwLock;
|
||||
use std::sync::{
|
||||
atomic::{AtomicBool, Ordering},
|
||||
Arc,
|
||||
|
@ -2289,8 +2294,7 @@ mod test {
|
|||
use super::*;
|
||||
|
||||
use crate::{EventEmitter, SyncRoom};
|
||||
use matrix_sdk_common::api::r0::sync::sync_events;
|
||||
use matrix_sdk_common::locks::RwLock;
|
||||
use matrix_sdk_common::{api::r0::sync::sync_events, locks::RwLock};
|
||||
use std::sync::{
|
||||
atomic::{AtomicBool, Ordering},
|
||||
Arc,
|
||||
|
|
|
@ -17,29 +17,31 @@ use std::sync::Arc;
|
|||
use matrix_sdk_common::locks::RwLock;
|
||||
use serde_json::value::RawValue as RawJsonValue;
|
||||
|
||||
use crate::events::{
|
||||
custom::CustomEventContent,
|
||||
fully_read::FullyReadEventContent,
|
||||
ignored_user_list::IgnoredUserListEventContent,
|
||||
presence::PresenceEvent,
|
||||
push_rules::PushRulesEventContent,
|
||||
receipt::ReceiptEventContent,
|
||||
room::{
|
||||
aliases::AliasesEventContent,
|
||||
avatar::AvatarEventContent,
|
||||
canonical_alias::CanonicalAliasEventContent,
|
||||
join_rules::JoinRulesEventContent,
|
||||
member::MemberEventContent,
|
||||
message::{feedback::FeedbackEventContent, MessageEventContent as MsgEventContent},
|
||||
name::NameEventContent,
|
||||
power_levels::PowerLevelsEventContent,
|
||||
redaction::SyncRedactionEvent,
|
||||
tombstone::TombstoneEventContent,
|
||||
use crate::{
|
||||
events::{
|
||||
custom::CustomEventContent,
|
||||
fully_read::FullyReadEventContent,
|
||||
ignored_user_list::IgnoredUserListEventContent,
|
||||
presence::PresenceEvent,
|
||||
push_rules::PushRulesEventContent,
|
||||
receipt::ReceiptEventContent,
|
||||
room::{
|
||||
aliases::AliasesEventContent,
|
||||
avatar::AvatarEventContent,
|
||||
canonical_alias::CanonicalAliasEventContent,
|
||||
join_rules::JoinRulesEventContent,
|
||||
member::MemberEventContent,
|
||||
message::{feedback::FeedbackEventContent, MessageEventContent as MsgEventContent},
|
||||
name::NameEventContent,
|
||||
power_levels::PowerLevelsEventContent,
|
||||
redaction::SyncRedactionEvent,
|
||||
tombstone::TombstoneEventContent,
|
||||
},
|
||||
typing::TypingEventContent,
|
||||
BasicEvent, StrippedStateEvent, SyncEphemeralRoomEvent, SyncMessageEvent, SyncStateEvent,
|
||||
},
|
||||
typing::TypingEventContent,
|
||||
BasicEvent, StrippedStateEvent, SyncEphemeralRoomEvent, SyncMessageEvent, SyncStateEvent,
|
||||
Room, RoomState,
|
||||
};
|
||||
use crate::{Room, RoomState};
|
||||
use matrix_sdk_common_macros::async_trait;
|
||||
|
||||
/// Type alias for `RoomState` enum when passed to `EventEmitter` methods.
|
||||
|
@ -471,8 +473,7 @@ mod test {
|
|||
}
|
||||
}
|
||||
|
||||
use crate::identifiers::UserId;
|
||||
use crate::{BaseClient, Session};
|
||||
use crate::{identifiers::UserId, BaseClient, Session};
|
||||
|
||||
use std::convert::TryFrom;
|
||||
|
||||
|
|
|
@ -35,7 +35,10 @@
|
|||
unused_qualifications
|
||||
)]
|
||||
|
||||
pub use crate::{error::Error, error::Result, session::Session};
|
||||
pub use crate::{
|
||||
error::{Error, Result},
|
||||
session::Session,
|
||||
};
|
||||
pub use matrix_sdk_common::*;
|
||||
|
||||
mod client;
|
||||
|
|
|
@ -5,11 +5,12 @@
|
|||
|
||||
use std::{time::SystemTime, vec::IntoIter};
|
||||
|
||||
use matrix_sdk_common::identifiers::{EventId, UserId};
|
||||
use matrix_sdk_common::{
|
||||
events::AnyPossiblyRedactedSyncMessageEvent,
|
||||
identifiers::{EventId, UserId},
|
||||
};
|
||||
use serde::{de, ser, Serialize};
|
||||
|
||||
use crate::events::AnyPossiblyRedactedSyncMessageEvent;
|
||||
|
||||
/// Exposes some of the field access methods found in the event held by
|
||||
/// `AnyPossiblyRedacted*` enums.
|
||||
///
|
||||
|
@ -160,8 +161,7 @@ pub(crate) mod ser_deser {
|
|||
|
||||
#[cfg(test)]
|
||||
mod test {
|
||||
use std::collections::HashMap;
|
||||
use std::convert::TryFrom;
|
||||
use std::{collections::HashMap, convert::TryFrom};
|
||||
|
||||
use matrix_sdk_common::{
|
||||
events::{AnyPossiblyRedactedSyncMessageEvent, AnySyncMessageEvent},
|
||||
|
|
|
@ -13,41 +13,42 @@
|
|||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
use std::collections::{BTreeMap, HashMap, HashSet};
|
||||
use std::convert::TryFrom;
|
||||
#[cfg(feature = "messages")]
|
||||
use std::ops::DerefMut;
|
||||
use std::{
|
||||
collections::{BTreeMap, HashMap, HashSet},
|
||||
convert::TryFrom,
|
||||
};
|
||||
|
||||
#[cfg(feature = "messages")]
|
||||
use matrix_sdk_common::events::{
|
||||
room::redaction::SyncRedactionEvent, AnyPossiblyRedactedSyncMessageEvent, AnySyncMessageEvent,
|
||||
};
|
||||
use matrix_sdk_common::{
|
||||
api::r0::sync::sync_events::{RoomSummary, UnreadNotificationsCount},
|
||||
events::{
|
||||
presence::{PresenceEvent, PresenceEventContent},
|
||||
room::{
|
||||
aliases::AliasesEventContent,
|
||||
canonical_alias::CanonicalAliasEventContent,
|
||||
encryption::EncryptionEventContent,
|
||||
member::{MemberEventContent, MembershipChange, MembershipState},
|
||||
name::NameEventContent,
|
||||
power_levels::{NotificationPowerLevels, PowerLevelsEventContent},
|
||||
tombstone::TombstoneEventContent,
|
||||
},
|
||||
Algorithm, AnyStrippedStateEvent, AnySyncRoomEvent, AnySyncStateEvent, EventType,
|
||||
StrippedStateEvent, SyncStateEvent,
|
||||
},
|
||||
identifiers::{RoomAliasId, RoomId, UserId},
|
||||
js_int::{int, uint, Int, UInt},
|
||||
};
|
||||
use serde::{Deserialize, Serialize};
|
||||
use tracing::{debug, error, trace};
|
||||
|
||||
#[cfg(feature = "messages")]
|
||||
use super::message::MessageQueue;
|
||||
use super::RoomMember;
|
||||
use crate::api::r0::sync::sync_events::{RoomSummary, UnreadNotificationsCount};
|
||||
use crate::events::{
|
||||
presence::{PresenceEvent, PresenceEventContent},
|
||||
room::{
|
||||
aliases::AliasesEventContent,
|
||||
canonical_alias::CanonicalAliasEventContent,
|
||||
encryption::EncryptionEventContent,
|
||||
member::{MemberEventContent, MembershipChange, MembershipState},
|
||||
name::NameEventContent,
|
||||
power_levels::{NotificationPowerLevels, PowerLevelsEventContent},
|
||||
tombstone::TombstoneEventContent,
|
||||
},
|
||||
Algorithm, AnyStrippedStateEvent, AnySyncRoomEvent, AnySyncStateEvent, EventType,
|
||||
StrippedStateEvent, SyncStateEvent,
|
||||
};
|
||||
|
||||
#[cfg(feature = "messages")]
|
||||
use crate::events::{
|
||||
room::redaction::SyncRedactionEvent, AnyPossiblyRedactedSyncMessageEvent, AnySyncMessageEvent,
|
||||
};
|
||||
|
||||
use crate::identifiers::{RoomAliasId, RoomId, UserId};
|
||||
|
||||
use crate::js_int::{int, uint, Int, UInt};
|
||||
|
||||
#[derive(Clone, Debug, Default, PartialEq, Serialize, Deserialize)]
|
||||
/// `RoomName` allows the calculation of a text room name.
|
||||
|
@ -670,8 +671,7 @@ impl Room {
|
|||
#[cfg(feature = "messages")]
|
||||
#[cfg_attr(docsrs, doc(cfg(feature = "messages")))]
|
||||
pub fn handle_redaction(&mut self, redacted_event: &SyncRedactionEvent) -> bool {
|
||||
use crate::identifiers::RoomVersionId;
|
||||
use crate::models::message::PossiblyRedactedExt;
|
||||
use crate::{identifiers::RoomVersionId, models::message::PossiblyRedactedExt};
|
||||
|
||||
if let Some(mut msg) = self
|
||||
.messages
|
||||
|
@ -1080,9 +1080,11 @@ impl Describe for MembershipChange {
|
|||
#[cfg(test)]
|
||||
mod test {
|
||||
use super::*;
|
||||
use crate::events::{room::encryption::EncryptionEventContent, Unsigned};
|
||||
use crate::identifiers::{EventId, UserId};
|
||||
use crate::{BaseClient, Raw, Session};
|
||||
use crate::{
|
||||
events::{room::encryption::EncryptionEventContent, Unsigned},
|
||||
identifiers::{EventId, UserId},
|
||||
BaseClient, Raw, Session,
|
||||
};
|
||||
use matrix_sdk_test::{async_test, sync_response, EventBuilder, EventsJson, SyncResponseFile};
|
||||
|
||||
use std::time::SystemTime;
|
||||
|
@ -1090,8 +1092,7 @@ mod test {
|
|||
#[cfg(target_arch = "wasm32")]
|
||||
use wasm_bindgen_test::*;
|
||||
|
||||
use std::convert::TryFrom;
|
||||
use std::ops::Deref;
|
||||
use std::{convert::TryFrom, ops::Deref};
|
||||
|
||||
async fn get_client() -> BaseClient {
|
||||
let session = Session {
|
||||
|
|
|
@ -154,8 +154,10 @@ impl RoomMember {
|
|||
mod test {
|
||||
use matrix_sdk_test::{async_test, EventBuilder, EventsJson};
|
||||
|
||||
use crate::identifiers::{RoomId, UserId};
|
||||
use crate::{BaseClient, Session};
|
||||
use crate::{
|
||||
identifiers::{RoomId, UserId},
|
||||
BaseClient, Session,
|
||||
};
|
||||
|
||||
use crate::js_int::int;
|
||||
|
||||
|
|
|
@ -15,7 +15,7 @@
|
|||
|
||||
//! User sessions.
|
||||
|
||||
use crate::identifiers::{DeviceId, UserId};
|
||||
use matrix_sdk_common::identifiers::{DeviceId, UserId};
|
||||
|
||||
/// A user session, containing an access token and information about the
|
||||
/// associated user account.
|
||||
|
|
|
@ -1,16 +1,15 @@
|
|||
use std::collections::HashMap;
|
||||
use std::fmt;
|
||||
use std::fs;
|
||||
use std::path::{Path, PathBuf};
|
||||
use std::sync::{
|
||||
atomic::{AtomicBool, Ordering},
|
||||
Arc,
|
||||
use std::{
|
||||
collections::HashMap,
|
||||
fmt, fs,
|
||||
path::{Path, PathBuf},
|
||||
sync::{
|
||||
atomic::{AtomicBool, Ordering},
|
||||
Arc,
|
||||
},
|
||||
};
|
||||
|
||||
use matrix_sdk_common::identifiers::RoomId;
|
||||
use matrix_sdk_common::locks::RwLock;
|
||||
use tokio::fs as async_fs;
|
||||
use tokio::io::AsyncWriteExt;
|
||||
use matrix_sdk_common::{identifiers::RoomId, locks::RwLock};
|
||||
use tokio::{fs as async_fs, io::AsyncWriteExt};
|
||||
|
||||
use super::{AllRooms, ClientState, StateStore};
|
||||
use crate::{Error, Result, Room, RoomState, Session};
|
||||
|
@ -218,14 +217,15 @@ impl StateStore for JsonStore {
|
|||
mod test {
|
||||
use super::*;
|
||||
|
||||
use std::convert::TryFrom;
|
||||
use std::path::PathBuf;
|
||||
use std::{convert::TryFrom, path::PathBuf};
|
||||
|
||||
use tempfile::tempdir;
|
||||
|
||||
use crate::identifiers::{RoomId, UserId};
|
||||
use crate::push::Ruleset;
|
||||
use crate::{BaseClient, BaseClientConfig, Session};
|
||||
use crate::{
|
||||
identifiers::{RoomId, UserId},
|
||||
push::Ruleset,
|
||||
BaseClient, BaseClientConfig, Session,
|
||||
};
|
||||
|
||||
use matrix_sdk_test::{sync_response, SyncResponseFile};
|
||||
|
||||
|
|
|
@ -15,6 +15,10 @@
|
|||
|
||||
use std::collections::HashMap;
|
||||
|
||||
use matrix_sdk_common::{
|
||||
identifiers::{RoomId, UserId},
|
||||
push::Ruleset,
|
||||
};
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
#[cfg(not(target_arch = "wasm32"))]
|
||||
|
@ -22,10 +26,10 @@ mod json_store;
|
|||
#[cfg(not(target_arch = "wasm32"))]
|
||||
pub use json_store::JsonStore;
|
||||
|
||||
use crate::client::{BaseClient, Token};
|
||||
use crate::identifiers::{RoomId, UserId};
|
||||
use crate::push::Ruleset;
|
||||
use crate::{Result, Room, RoomState, Session};
|
||||
use crate::{
|
||||
client::{BaseClient, Token},
|
||||
Result, Room, RoomState, Session,
|
||||
};
|
||||
|
||||
#[cfg(not(target_arch = "wasm32"))]
|
||||
use matrix_sdk_common_macros::send_sync;
|
||||
|
@ -117,8 +121,7 @@ pub trait StateStore {
|
|||
mod test {
|
||||
use super::*;
|
||||
|
||||
use std::collections::HashMap;
|
||||
use std::convert::TryFrom;
|
||||
use std::{collections::HashMap, convert::TryFrom};
|
||||
|
||||
use crate::identifiers::RoomId;
|
||||
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
pub use instant;
|
||||
pub use js_int;
|
||||
|
||||
pub use ruma::{
|
||||
api::{
|
||||
client as api,
|
||||
|
|
|
@ -12,22 +12,27 @@
|
|||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
use std::collections::BTreeMap;
|
||||
use std::convert::TryFrom;
|
||||
use std::sync::atomic::{AtomicBool, Ordering};
|
||||
use std::sync::Arc;
|
||||
use std::{
|
||||
collections::BTreeMap,
|
||||
convert::TryFrom,
|
||||
sync::{
|
||||
atomic::{AtomicBool, Ordering},
|
||||
Arc,
|
||||
},
|
||||
};
|
||||
|
||||
use atomic::Atomic;
|
||||
use matrix_sdk_common::{
|
||||
api::r0::keys::{AlgorithmAndDeviceId, DeviceKeys, KeyAlgorithm, SignedKey},
|
||||
events::Algorithm,
|
||||
identifiers::{DeviceId, UserId},
|
||||
};
|
||||
use serde_json::{json, Value};
|
||||
|
||||
#[cfg(test)]
|
||||
use super::{Account, OlmMachine};
|
||||
use matrix_sdk_common::api::r0::keys::{AlgorithmAndDeviceId, DeviceKeys, KeyAlgorithm, SignedKey};
|
||||
use matrix_sdk_common::events::Algorithm;
|
||||
use matrix_sdk_common::identifiers::{DeviceId, UserId};
|
||||
|
||||
use crate::error::SignatureError;
|
||||
use crate::verify_json;
|
||||
use crate::{error::SignatureError, verify_json};
|
||||
|
||||
/// A device represents a E2EE capable client of an user.
|
||||
#[derive(Debug, Clone)]
|
||||
|
@ -243,8 +248,10 @@ pub(crate) mod test {
|
|||
use std::convert::TryFrom;
|
||||
|
||||
use crate::device::{Device, TrustState};
|
||||
use matrix_sdk_common::api::r0::keys::{DeviceKeys, KeyAlgorithm};
|
||||
use matrix_sdk_common::identifiers::UserId;
|
||||
use matrix_sdk_common::{
|
||||
api::r0::keys::{DeviceKeys, KeyAlgorithm},
|
||||
identifiers::UserId,
|
||||
};
|
||||
|
||||
fn device_keys() -> DeviceKeys {
|
||||
let device_keys = json!({
|
||||
|
|
|
@ -45,8 +45,10 @@ pub use store::{CryptoStore, CryptoStoreError};
|
|||
pub use verification::Sas;
|
||||
|
||||
use error::SignatureError;
|
||||
use matrix_sdk_common::api::r0::keys::{AlgorithmAndDeviceId, KeyAlgorithm};
|
||||
use matrix_sdk_common::identifiers::UserId;
|
||||
use matrix_sdk_common::{
|
||||
api::r0::keys::{AlgorithmAndDeviceId, KeyAlgorithm},
|
||||
identifiers::UserId,
|
||||
};
|
||||
use olm_rs::utility::OlmUtility;
|
||||
use serde_json::Value;
|
||||
|
||||
|
|
|
@ -12,45 +12,53 @@
|
|||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
use std::collections::{BTreeMap, HashMap, HashSet};
|
||||
use std::convert::{TryFrom, TryInto};
|
||||
use std::mem;
|
||||
#[cfg(feature = "sqlite-cryptostore")]
|
||||
use std::path::Path;
|
||||
use std::result::Result as StdResult;
|
||||
use std::sync::Arc;
|
||||
|
||||
use super::error::{EventError, MegolmError, MegolmResult, OlmError, OlmResult};
|
||||
use super::olm::{
|
||||
Account, GroupSessionKey, IdentityKeys, InboundGroupSession, OlmMessage, OutboundGroupSession,
|
||||
use std::{
|
||||
collections::{BTreeMap, HashMap, HashSet},
|
||||
convert::{TryFrom, TryInto},
|
||||
mem,
|
||||
result::Result as StdResult,
|
||||
sync::Arc,
|
||||
};
|
||||
use super::store::memorystore::MemoryStore;
|
||||
#[cfg(feature = "sqlite-cryptostore")]
|
||||
use super::store::sqlite::SqliteStore;
|
||||
use super::{device::Device, store::Result as StoreResult, CryptoStore};
|
||||
use crate::verification::{Sas, VerificationMachine};
|
||||
|
||||
use matrix_sdk_common::events::{
|
||||
forwarded_room_key::ForwardedRoomKeyEventContent, room::encrypted::EncryptedEventContent,
|
||||
room::message::MessageEventContent, room_key::RoomKeyEventContent,
|
||||
room_key_request::RoomKeyRequestEventContent, Algorithm, AnySyncRoomEvent, AnyToDeviceEvent,
|
||||
EventType, SyncMessageEvent, ToDeviceEvent,
|
||||
};
|
||||
use matrix_sdk_common::identifiers::{DeviceId, RoomId, UserId};
|
||||
use matrix_sdk_common::locks::RwLock;
|
||||
use matrix_sdk_common::uuid::Uuid;
|
||||
use matrix_sdk_common::{api, Raw};
|
||||
|
||||
use api::r0::keys;
|
||||
use api::r0::{
|
||||
keys,
|
||||
keys::{AlgorithmAndDeviceId, DeviceKeys, KeyAlgorithm, OneTimeKey},
|
||||
sync::sync_events::Response as SyncResponse,
|
||||
to_device::{send_event_to_device::Request as ToDeviceRequest, DeviceIdOrAllDevices},
|
||||
};
|
||||
|
||||
use matrix_sdk_common::{
|
||||
api,
|
||||
events::{
|
||||
forwarded_room_key::ForwardedRoomKeyEventContent,
|
||||
room::{encrypted::EncryptedEventContent, message::MessageEventContent},
|
||||
room_key::RoomKeyEventContent,
|
||||
room_key_request::RoomKeyRequestEventContent,
|
||||
Algorithm, AnySyncRoomEvent, AnyToDeviceEvent, EventType, SyncMessageEvent, ToDeviceEvent,
|
||||
},
|
||||
identifiers::{DeviceId, RoomId, UserId},
|
||||
locks::RwLock,
|
||||
uuid::Uuid,
|
||||
Raw,
|
||||
};
|
||||
use serde_json::Value;
|
||||
use tracing::{debug, error, info, instrument, trace, warn};
|
||||
|
||||
#[cfg(feature = "sqlite-cryptostore")]
|
||||
use super::store::sqlite::SqliteStore;
|
||||
use super::{
|
||||
device::Device,
|
||||
error::{EventError, MegolmError, MegolmResult, OlmError, OlmResult},
|
||||
olm::{
|
||||
Account, GroupSessionKey, IdentityKeys, InboundGroupSession, OlmMessage,
|
||||
OutboundGroupSession,
|
||||
},
|
||||
store::{memorystore::MemoryStore, Result as StoreResult},
|
||||
verification::{Sas, VerificationMachine},
|
||||
CryptoStore,
|
||||
};
|
||||
|
||||
/// A map from the algorithm and device id to a one-time key.
|
||||
///
|
||||
/// These keys need to be periodically uploaded to the server.
|
||||
|
@ -1262,30 +1270,33 @@ mod test {
|
|||
static USER_ID: &str = "@bob:example.org";
|
||||
|
||||
use matrix_sdk_common::js_int::uint;
|
||||
use std::collections::BTreeMap;
|
||||
use std::convert::TryFrom;
|
||||
use std::convert::TryInto;
|
||||
use std::time::SystemTime;
|
||||
use std::{
|
||||
collections::BTreeMap,
|
||||
convert::{TryFrom, TryInto},
|
||||
time::SystemTime,
|
||||
};
|
||||
|
||||
use http::Response;
|
||||
use serde_json::json;
|
||||
|
||||
use crate::machine::{OlmMachine, OneTimeKeys};
|
||||
use crate::{verify_json, Device};
|
||||
use crate::{
|
||||
machine::{OlmMachine, OneTimeKeys},
|
||||
verify_json, Device,
|
||||
};
|
||||
|
||||
use matrix_sdk_common::api::r0::{
|
||||
keys, to_device::send_event_to_device::Request as ToDeviceRequest,
|
||||
};
|
||||
use matrix_sdk_common::events::{
|
||||
room::{
|
||||
encrypted::EncryptedEventContent,
|
||||
message::{MessageEventContent, TextMessageEventContent},
|
||||
use matrix_sdk_common::{
|
||||
api::r0::{keys, to_device::send_event_to_device::Request as ToDeviceRequest},
|
||||
events::{
|
||||
room::{
|
||||
encrypted::EncryptedEventContent,
|
||||
message::{MessageEventContent, TextMessageEventContent},
|
||||
},
|
||||
AnySyncMessageEvent, AnySyncRoomEvent, AnyToDeviceEvent, EventType, SyncMessageEvent,
|
||||
ToDeviceEvent, Unsigned,
|
||||
},
|
||||
AnySyncMessageEvent, AnySyncRoomEvent, AnyToDeviceEvent, EventType, SyncMessageEvent,
|
||||
ToDeviceEvent, Unsigned,
|
||||
identifiers::{DeviceId, EventId, RoomId, UserId},
|
||||
Raw,
|
||||
};
|
||||
use matrix_sdk_common::identifiers::{DeviceId, EventId, RoomId, UserId};
|
||||
use matrix_sdk_common::Raw;
|
||||
use matrix_sdk_test::test_json;
|
||||
|
||||
fn alice_id() -> UserId {
|
||||
|
|
|
@ -12,15 +12,18 @@
|
|||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
use std::collections::HashMap;
|
||||
use std::sync::Arc;
|
||||
use std::{collections::HashMap, sync::Arc};
|
||||
|
||||
use dashmap::{DashMap, ReadOnlyView};
|
||||
use matrix_sdk_common::locks::Mutex;
|
||||
use matrix_sdk_common::{
|
||||
identifiers::{DeviceId, RoomId, UserId},
|
||||
locks::Mutex,
|
||||
};
|
||||
|
||||
use super::device::Device;
|
||||
use super::olm::{InboundGroupSession, Session};
|
||||
use matrix_sdk_common::identifiers::{DeviceId, RoomId, UserId};
|
||||
use super::{
|
||||
device::Device,
|
||||
olm::{InboundGroupSession, Session},
|
||||
};
|
||||
|
||||
/// In-memory store for Olm Sessions.
|
||||
#[derive(Debug, Default)]
|
||||
|
@ -211,10 +214,11 @@ impl DeviceStore {
|
|||
mod test {
|
||||
use std::convert::TryFrom;
|
||||
|
||||
use crate::device::test::get_device;
|
||||
use crate::memory_stores::{DeviceStore, GroupSessionStore, SessionStore};
|
||||
use crate::olm::test::get_account_and_session;
|
||||
use crate::olm::InboundGroupSession;
|
||||
use crate::{
|
||||
device::test::get_device,
|
||||
memory_stores::{DeviceStore, GroupSessionStore, SessionStore},
|
||||
olm::{test::get_account_and_session, InboundGroupSession},
|
||||
};
|
||||
use matrix_sdk_common::identifiers::RoomId;
|
||||
|
||||
#[tokio::test]
|
||||
|
|
|
@ -12,36 +12,38 @@
|
|||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
use matrix_sdk_common::instant::Instant;
|
||||
use std::convert::TryFrom;
|
||||
use std::convert::TryInto;
|
||||
use std::fmt;
|
||||
use std::sync::atomic::{AtomicBool, AtomicI64, Ordering};
|
||||
use std::sync::Arc;
|
||||
|
||||
use matrix_sdk_common::locks::Mutex;
|
||||
use serde_json::{json, Value};
|
||||
use std::collections::BTreeMap;
|
||||
|
||||
pub use olm_rs::account::IdentityKeys;
|
||||
use olm_rs::account::{OlmAccount, OneTimeKeys};
|
||||
use olm_rs::errors::{OlmAccountError, OlmSessionError};
|
||||
use olm_rs::PicklingMode;
|
||||
|
||||
use crate::device::Device;
|
||||
use crate::error::SessionCreationError;
|
||||
pub use olm_rs::{
|
||||
session::{OlmMessage, PreKeyMessage},
|
||||
utility::OlmUtility,
|
||||
use std::{
|
||||
collections::BTreeMap,
|
||||
convert::{TryFrom, TryInto},
|
||||
fmt,
|
||||
sync::{
|
||||
atomic::{AtomicBool, AtomicI64, Ordering},
|
||||
Arc,
|
||||
},
|
||||
};
|
||||
|
||||
use matrix_sdk_common::{
|
||||
api::r0::keys::{AlgorithmAndDeviceId, DeviceKeys, KeyAlgorithm, OneTimeKey, SignedKey},
|
||||
events::Algorithm,
|
||||
identifiers::{DeviceId, RoomId, UserId},
|
||||
instant::Instant,
|
||||
locks::Mutex,
|
||||
};
|
||||
use olm_rs::{
|
||||
account::{OlmAccount, OneTimeKeys},
|
||||
errors::{OlmAccountError, OlmSessionError},
|
||||
PicklingMode,
|
||||
};
|
||||
use serde_json::{json, Value};
|
||||
|
||||
pub use olm_rs::{
|
||||
account::IdentityKeys,
|
||||
session::{OlmMessage, PreKeyMessage},
|
||||
utility::OlmUtility,
|
||||
};
|
||||
|
||||
use super::{InboundGroupSession, OutboundGroupSession, Session};
|
||||
use crate::{device::Device, error::SessionCreationError};
|
||||
|
||||
/// Account holding identity keys for which sessions can be created.
|
||||
///
|
||||
|
|
|
@ -12,27 +12,13 @@
|
|||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
use matrix_sdk_common::instant::Instant;
|
||||
use std::convert::TryInto;
|
||||
use std::fmt;
|
||||
use std::sync::atomic::{AtomicBool, AtomicUsize, Ordering};
|
||||
use std::sync::Arc;
|
||||
|
||||
use matrix_sdk_common::locks::Mutex;
|
||||
use serde::Serialize;
|
||||
use serde_json::{json, Value};
|
||||
use zeroize::Zeroize;
|
||||
|
||||
pub use olm_rs::account::IdentityKeys;
|
||||
use olm_rs::errors::OlmGroupSessionError;
|
||||
use olm_rs::inbound_group_session::OlmInboundGroupSession;
|
||||
use olm_rs::outbound_group_session::OlmOutboundGroupSession;
|
||||
use olm_rs::PicklingMode;
|
||||
|
||||
use crate::error::{EventError, MegolmResult};
|
||||
pub use olm_rs::{
|
||||
session::{OlmMessage, PreKeyMessage},
|
||||
utility::OlmUtility,
|
||||
use std::{
|
||||
convert::TryInto,
|
||||
fmt,
|
||||
sync::{
|
||||
atomic::{AtomicBool, AtomicUsize, Ordering},
|
||||
Arc,
|
||||
},
|
||||
};
|
||||
|
||||
use matrix_sdk_common::{
|
||||
|
@ -41,8 +27,25 @@ use matrix_sdk_common::{
|
|||
Algorithm, AnySyncRoomEvent, EventType, SyncMessageEvent,
|
||||
},
|
||||
identifiers::{DeviceId, RoomId},
|
||||
instant::Instant,
|
||||
locks::Mutex,
|
||||
Raw,
|
||||
};
|
||||
use olm_rs::{
|
||||
errors::OlmGroupSessionError, inbound_group_session::OlmInboundGroupSession,
|
||||
outbound_group_session::OlmOutboundGroupSession, PicklingMode,
|
||||
};
|
||||
use serde::Serialize;
|
||||
use serde_json::{json, Value};
|
||||
use zeroize::Zeroize;
|
||||
|
||||
pub use olm_rs::{
|
||||
account::IdentityKeys,
|
||||
session::{OlmMessage, PreKeyMessage},
|
||||
utility::OlmUtility,
|
||||
};
|
||||
|
||||
use crate::error::{EventError, MegolmResult};
|
||||
|
||||
/// The private session key of a group session.
|
||||
/// Can be used to create a new inbound group session.
|
||||
|
|
|
@ -23,11 +23,12 @@ pub use session::{OlmMessage, Session};
|
|||
#[cfg(test)]
|
||||
pub(crate) mod test {
|
||||
use crate::olm::{Account, InboundGroupSession, Session};
|
||||
use matrix_sdk_common::api::r0::keys::SignedKey;
|
||||
use matrix_sdk_common::identifiers::{DeviceId, RoomId, UserId};
|
||||
use matrix_sdk_common::{
|
||||
api::r0::keys::SignedKey,
|
||||
identifiers::{DeviceId, RoomId, UserId},
|
||||
};
|
||||
use olm_rs::session::OlmMessage;
|
||||
use std::collections::BTreeMap;
|
||||
use std::convert::TryFrom;
|
||||
use std::{collections::BTreeMap, convert::TryFrom};
|
||||
|
||||
fn alice_id() -> UserId {
|
||||
UserId::try_from("@alice:example.org").unwrap()
|
||||
|
|
|
@ -12,24 +12,7 @@
|
|||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
use std::collections::BTreeMap;
|
||||
use std::fmt;
|
||||
use std::sync::Arc;
|
||||
|
||||
use olm_rs::errors::OlmSessionError;
|
||||
use olm_rs::session::OlmSession;
|
||||
use olm_rs::PicklingMode;
|
||||
|
||||
use serde_json::{json, Value};
|
||||
|
||||
pub use olm_rs::{
|
||||
session::{OlmMessage, PreKeyMessage},
|
||||
utility::OlmUtility,
|
||||
};
|
||||
|
||||
use super::IdentityKeys;
|
||||
use crate::error::{EventError, OlmResult};
|
||||
use crate::Device;
|
||||
use std::{collections::BTreeMap, fmt, sync::Arc};
|
||||
|
||||
use matrix_sdk_common::{
|
||||
api::r0::keys::KeyAlgorithm,
|
||||
|
@ -41,6 +24,19 @@ use matrix_sdk_common::{
|
|||
instant::Instant,
|
||||
locks::Mutex,
|
||||
};
|
||||
use olm_rs::{errors::OlmSessionError, session::OlmSession, PicklingMode};
|
||||
use serde_json::{json, Value};
|
||||
|
||||
use super::IdentityKeys;
|
||||
use crate::{
|
||||
error::{EventError, OlmResult},
|
||||
Device,
|
||||
};
|
||||
|
||||
pub use olm_rs::{
|
||||
session::{OlmMessage, PreKeyMessage},
|
||||
utility::OlmUtility,
|
||||
};
|
||||
|
||||
/// Cryptographic session that enables secure communication between two
|
||||
/// `Account`s
|
||||
|
|
|
@ -12,17 +12,19 @@
|
|||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
use std::collections::HashSet;
|
||||
use std::sync::Arc;
|
||||
use std::{collections::HashSet, sync::Arc};
|
||||
|
||||
use async_trait::async_trait;
|
||||
use matrix_sdk_common::locks::Mutex;
|
||||
use matrix_sdk_common::{
|
||||
identifiers::{DeviceId, RoomId, UserId},
|
||||
locks::Mutex,
|
||||
};
|
||||
|
||||
use super::{Account, CryptoStore, InboundGroupSession, Result, Session};
|
||||
use crate::device::Device;
|
||||
use crate::memory_stores::{DeviceStore, GroupSessionStore, SessionStore, UserDevices};
|
||||
use matrix_sdk_common::identifiers::{DeviceId, RoomId, UserId};
|
||||
|
||||
use crate::{
|
||||
device::Device,
|
||||
memory_stores::{DeviceStore, GroupSessionStore, SessionStore, UserDevices},
|
||||
};
|
||||
#[derive(Debug)]
|
||||
pub struct MemoryStore {
|
||||
sessions: SessionStore,
|
||||
|
@ -126,11 +128,11 @@ impl CryptoStore for MemoryStore {
|
|||
mod test {
|
||||
use std::convert::TryFrom;
|
||||
|
||||
use crate::device::test::get_device;
|
||||
use crate::olm::test::get_account_and_session;
|
||||
use crate::olm::InboundGroupSession;
|
||||
use crate::store::memorystore::MemoryStore;
|
||||
use crate::store::CryptoStore;
|
||||
use crate::{
|
||||
device::test::get_device,
|
||||
olm::{test::get_account_and_session, InboundGroupSession},
|
||||
store::{memorystore::MemoryStore, CryptoStore},
|
||||
};
|
||||
use matrix_sdk_common::identifiers::RoomId;
|
||||
|
||||
#[tokio::test]
|
||||
|
|
|
@ -12,23 +12,25 @@
|
|||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
use core::fmt::Debug;
|
||||
use std::collections::HashSet;
|
||||
use std::io::Error as IoError;
|
||||
use std::sync::Arc;
|
||||
use url::ParseError;
|
||||
use std::{collections::HashSet, io::Error as IoError, sync::Arc};
|
||||
|
||||
use async_trait::async_trait;
|
||||
use matrix_sdk_common::locks::Mutex;
|
||||
use serde_json::Error as SerdeError;
|
||||
use thiserror::Error;
|
||||
|
||||
use super::device::Device;
|
||||
use super::memory_stores::UserDevices;
|
||||
use super::olm::{Account, InboundGroupSession, Session};
|
||||
use matrix_sdk_common::identifiers::{DeviceId, RoomId, UserId};
|
||||
use core::fmt::Debug;
|
||||
use matrix_sdk_common::{
|
||||
identifiers::{DeviceId, RoomId, UserId},
|
||||
locks::Mutex,
|
||||
};
|
||||
use matrix_sdk_common_macros::send_sync;
|
||||
use olm_rs::errors::{OlmAccountError, OlmGroupSessionError, OlmSessionError};
|
||||
use serde_json::Error as SerdeError;
|
||||
use thiserror::Error;
|
||||
use url::ParseError;
|
||||
|
||||
use super::{
|
||||
device::Device,
|
||||
memory_stores::UserDevices,
|
||||
olm::{Account, InboundGroupSession, Session},
|
||||
};
|
||||
|
||||
pub mod memorystore;
|
||||
|
||||
|
|
|
@ -12,27 +12,33 @@
|
|||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
use matrix_sdk_common::instant::{Duration, Instant};
|
||||
use std::collections::{BTreeMap, HashSet};
|
||||
use std::convert::TryFrom;
|
||||
use std::path::{Path, PathBuf};
|
||||
use std::result::Result as StdResult;
|
||||
use std::sync::Arc;
|
||||
use url::Url;
|
||||
use std::{
|
||||
collections::{BTreeMap, HashSet},
|
||||
convert::TryFrom,
|
||||
path::{Path, PathBuf},
|
||||
result::Result as StdResult,
|
||||
sync::Arc,
|
||||
};
|
||||
|
||||
use async_trait::async_trait;
|
||||
use matrix_sdk_common::locks::Mutex;
|
||||
use matrix_sdk_common::{
|
||||
api::r0::keys::{AlgorithmAndDeviceId, KeyAlgorithm},
|
||||
events::Algorithm,
|
||||
identifiers::{DeviceId, RoomId, UserId},
|
||||
instant::{Duration, Instant},
|
||||
locks::Mutex,
|
||||
};
|
||||
use olm_rs::PicklingMode;
|
||||
use sqlx::{query, query_as, sqlite::SqliteQueryAs, Connect, Executor, SqliteConnection};
|
||||
use url::Url;
|
||||
use zeroize::Zeroizing;
|
||||
|
||||
use super::{CryptoStore, CryptoStoreError, Result};
|
||||
use crate::device::{Device, TrustState};
|
||||
use crate::memory_stores::{DeviceStore, GroupSessionStore, SessionStore, UserDevices};
|
||||
use crate::{Account, IdentityKeys, InboundGroupSession, Session};
|
||||
use matrix_sdk_common::api::r0::keys::{AlgorithmAndDeviceId, KeyAlgorithm};
|
||||
use matrix_sdk_common::events::Algorithm;
|
||||
use matrix_sdk_common::identifiers::{DeviceId, RoomId, UserId};
|
||||
use crate::{
|
||||
device::{Device, TrustState},
|
||||
memory_stores::{DeviceStore, GroupSessionStore, SessionStore, UserDevices},
|
||||
Account, IdentityKeys, InboundGroupSession, Session,
|
||||
};
|
||||
|
||||
/// SQLite based implementation of a `CryptoStore`.
|
||||
pub struct SqliteStore {
|
||||
|
@ -887,10 +893,11 @@ impl std::fmt::Debug for SqliteStore {
|
|||
|
||||
#[cfg(test)]
|
||||
mod test {
|
||||
use crate::device::test::get_device;
|
||||
use crate::olm::GroupSessionKey;
|
||||
use matrix_sdk_common::api::r0::keys::SignedKey;
|
||||
use matrix_sdk_common::identifiers::{DeviceId, UserId};
|
||||
use crate::{device::test::get_device, olm::GroupSessionKey};
|
||||
use matrix_sdk_common::{
|
||||
api::r0::keys::SignedKey,
|
||||
identifiers::{DeviceId, UserId},
|
||||
};
|
||||
use olm_rs::outbound_group_session::OlmOutboundGroupSession;
|
||||
use std::collections::BTreeMap;
|
||||
use tempfile::tempdir;
|
||||
|
|
|
@ -160,8 +160,7 @@ impl VerificationMachine {
|
|||
#[cfg(test)]
|
||||
mod test {
|
||||
|
||||
use std::convert::TryFrom;
|
||||
use std::sync::Arc;
|
||||
use std::{convert::TryFrom, sync::Arc};
|
||||
|
||||
use matrix_sdk_common::{
|
||||
events::AnyToDeviceEventContent,
|
||||
|
@ -170,8 +169,11 @@ mod test {
|
|||
};
|
||||
|
||||
use super::{Sas, VerificationMachine};
|
||||
use crate::verification::test::{get_content_from_request, wrap_any_to_device_content};
|
||||
use crate::{store::memorystore::MemoryStore, Account, CryptoStore, Device};
|
||||
use crate::{
|
||||
store::memorystore::MemoryStore,
|
||||
verification::test::{get_content_from_request, wrap_any_to_device_content},
|
||||
Account, CryptoStore, Device,
|
||||
};
|
||||
|
||||
fn alice_id() -> UserId {
|
||||
UserId::try_from("@alice:example.org").unwrap()
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
use std::collections::BTreeMap;
|
||||
use std::convert::TryInto;
|
||||
use std::{collections::BTreeMap, convert::TryInto};
|
||||
|
||||
use olm_rs::sas::OlmSas;
|
||||
|
||||
|
|
|
@ -491,12 +491,13 @@ impl InnerSas {
|
|||
|
||||
#[cfg(test)]
|
||||
mod test {
|
||||
use std::convert::TryFrom;
|
||||
use std::sync::Arc;
|
||||
use std::{convert::TryFrom, sync::Arc};
|
||||
|
||||
use matrix_sdk_common::events::{EventContent, ToDeviceEvent};
|
||||
use matrix_sdk_common::identifiers::{DeviceId, UserId};
|
||||
use matrix_sdk_common::locks::RwLock;
|
||||
use matrix_sdk_common::{
|
||||
events::{EventContent, ToDeviceEvent},
|
||||
identifiers::{DeviceId, UserId},
|
||||
locks::RwLock,
|
||||
};
|
||||
|
||||
use crate::{
|
||||
store::memorystore::MemoryStore,
|
||||
|
|
|
@ -744,8 +744,10 @@ mod test {
|
|||
use std::convert::TryFrom;
|
||||
|
||||
use crate::{Account, Device};
|
||||
use matrix_sdk_common::events::{EventContent, ToDeviceEvent};
|
||||
use matrix_sdk_common::identifiers::{DeviceId, UserId};
|
||||
use matrix_sdk_common::{
|
||||
events::{EventContent, ToDeviceEvent},
|
||||
identifiers::{DeviceId, UserId},
|
||||
};
|
||||
|
||||
use super::{Accepted, Created, SasState, Started};
|
||||
|
||||
|
|
|
@ -1,15 +1,15 @@
|
|||
use std::collections::HashMap;
|
||||
use std::convert::TryFrom;
|
||||
use std::panic;
|
||||
use std::{collections::HashMap, convert::TryFrom, panic};
|
||||
|
||||
use http::Response;
|
||||
|
||||
use matrix_sdk_common::api::r0::sync::sync_events::Response as SyncResponse;
|
||||
use matrix_sdk_common::events::{
|
||||
presence::PresenceEvent, AnyBasicEvent, AnySyncEphemeralRoomEvent, AnySyncRoomEvent,
|
||||
AnySyncStateEvent,
|
||||
use matrix_sdk_common::{
|
||||
api::r0::sync::sync_events::Response as SyncResponse,
|
||||
events::{
|
||||
presence::PresenceEvent, AnyBasicEvent, AnySyncEphemeralRoomEvent, AnySyncRoomEvent,
|
||||
AnySyncStateEvent,
|
||||
},
|
||||
identifiers::RoomId,
|
||||
};
|
||||
use matrix_sdk_common::identifiers::RoomId;
|
||||
use serde_json::Value as JsonValue;
|
||||
|
||||
pub use matrix_sdk_test_macros::async_test;
|
||||
|
|
Loading…
Reference in New Issue