diff --git a/matrix_sdk/src/client.rs b/matrix_sdk/src/client.rs index 74b61ef5..4e5f1126 100644 --- a/matrix_sdk/src/client.rs +++ b/matrix_sdk/src/client.rs @@ -13,11 +13,12 @@ // See the License for the specific language governing permissions and // limitations under the License. +#[cfg(all(feature = "encryption", not(target_arch = "wasm32")))] +use std::path::PathBuf; #[cfg(feature = "encryption")] use std::{ collections::BTreeMap, io::{Cursor, Write}, - path::PathBuf, }; #[cfg(feature = "sso_login")] use std::{ @@ -39,10 +40,12 @@ use futures_timer::Delay as sleep; use http::HeaderValue; #[cfg(feature = "sso_login")] use http::Response; +#[cfg(all(feature = "encryption", not(target_arch = "wasm32")))] +use matrix_sdk_base::crypto::{decrypt_key_export, encrypt_key_export, olm::InboundGroupSession}; #[cfg(feature = "encryption")] use matrix_sdk_base::crypto::{ - decrypt_key_export, encrypt_key_export, olm::InboundGroupSession, store::CryptoStoreError, - AttachmentDecryptor, OutgoingRequests, RoomMessageRequest, ToDeviceRequest, + store::CryptoStoreError, AttachmentDecryptor, OutgoingRequests, RoomMessageRequest, + ToDeviceRequest, }; use matrix_sdk_base::{ deserialized_responses::SyncResponse, @@ -64,7 +67,7 @@ use tracing::{error, info, instrument}; use url::Url; #[cfg(feature = "sso_login")] use warp::Filter; -#[cfg(feature = "encryption")] +#[cfg(all(feature = "encryption", not(target_arch = "wasm32")))] use zeroize::Zeroizing; /// Enum controlling if a loop running callbacks should continue or abort. @@ -2427,8 +2430,7 @@ impl Client { /// .expect("Can't export keys."); /// # }); /// ``` - #[cfg(feature = "encryption")] - #[cfg(not(target_arch = "wasm32"))] + #[cfg(all(feature = "encryption", not(target_arch = "wasm32")))] #[cfg_attr(feature = "docs", doc(cfg(all(encryption, not(target_arch = "wasm32")))))] pub async fn export_keys( &self, @@ -2487,8 +2489,7 @@ impl Client { /// .expect("Can't import keys"); /// # }); /// ``` - #[cfg(feature = "encryption")] - #[cfg(not(target_arch = "wasm32"))] + #[cfg(all(feature = "encryption", not(target_arch = "wasm32")))] #[cfg_attr(feature = "docs", doc(cfg(all(encryption, not(target_arch = "wasm32")))))] pub async fn import_keys(&self, path: PathBuf, passphrase: &str) -> Result<(usize, usize)> { let olm = self.base_client.olm_machine().await.ok_or(Error::AuthenticationRequired)?; diff --git a/matrix_sdk/src/http_client.rs b/matrix_sdk/src/http_client.rs index 6874b90f..ed5477a4 100644 --- a/matrix_sdk/src/http_client.rs +++ b/matrix_sdk/src/http_client.rs @@ -12,16 +12,10 @@ // See the License for the specific language governing permissions and // limitations under the License. -#[cfg(all(not(target_arch = "wasm32")))] -use std::sync::atomic::{AtomicU64, Ordering}; use std::{convert::TryFrom, fmt::Debug, sync::Arc}; -#[cfg(all(not(target_arch = "wasm32")))] -use backoff::{future::retry, Error as RetryError, ExponentialBackoff}; use bytes::{Bytes, BytesMut}; -#[cfg(all(not(target_arch = "wasm32")))] -use http::StatusCode; -use http::{HeaderValue, Response as HttpResponse}; +use http::Response as HttpResponse; use matrix_sdk_common::{async_trait, locks::RwLock, AsyncTraitDeps}; use reqwest::{Client, Response}; use ruma::api::{ @@ -236,6 +230,8 @@ pub(crate) fn client_with_config(config: &ClientConfig) -> Result, config: RequestConfig, ) -> Result, HttpError> { + use std::sync::atomic::{AtomicU64, Ordering}; + + use backoff::{future::retry, Error as RetryError, ExponentialBackoff}; + use http::StatusCode; + let mut backoff = ExponentialBackoff::default(); let mut request = reqwest::Request::try_from(request)?; let retry_limit = config.retry_limit; diff --git a/matrix_sdk_crypto/src/verification/machine.rs b/matrix_sdk_crypto/src/verification/machine.rs index 9a1162fe..b5d1d60c 100644 --- a/matrix_sdk_crypto/src/verification/machine.rs +++ b/matrix_sdk_crypto/src/verification/machine.rs @@ -16,7 +16,7 @@ use std::{convert::TryFrom, sync::Arc}; use dashmap::DashMap; use matrix_sdk_common::{locks::Mutex, uuid::Uuid}; -use ruma::{uint, DeviceId, MilliSecondsSinceUnixEpoch, UInt, UserId}; +use ruma::{DeviceId, MilliSecondsSinceUnixEpoch, UserId}; use tracing::{info, trace, warn}; use super::{ @@ -123,6 +123,8 @@ impl VerificationMachine { #[cfg(not(target_arch = "wasm32"))] fn is_timestamp_valid(timestamp: &MilliSecondsSinceUnixEpoch) -> bool { + use ruma::{uint, UInt}; + // The event should be ignored if the event is older than 10 minutes let old_timestamp_threshold: UInt = uint!(600); // The event should be ignored if the event is 5 minutes or more into the