diff --git a/Cargo.lock b/Cargo.lock index 1e43acae6..81ddca421 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3060,6 +3060,7 @@ dependencies = [ "tracing", "uniffi", "wasm-bindgen-test", + "web-time", ] [[package]] @@ -4739,7 +4740,7 @@ dependencies = [ [[package]] name = "ruma" version = "0.9.4" -source = "git+https://github.com/ruma/ruma?rev=b2542df2bbbdf09af0612c9f28bcfa5620e1911c#b2542df2bbbdf09af0612c9f28bcfa5620e1911c" +source = "git+https://github.com/ruma/ruma?rev=4c00bd010dbdca6005bd599b52e90a0b7015d056#4c00bd010dbdca6005bd599b52e90a0b7015d056" dependencies = [ "assign", "js_int", @@ -4755,7 +4756,7 @@ dependencies = [ [[package]] name = "ruma-client-api" version = "0.17.4" -source = "git+https://github.com/ruma/ruma?rev=b2542df2bbbdf09af0612c9f28bcfa5620e1911c#b2542df2bbbdf09af0612c9f28bcfa5620e1911c" +source = "git+https://github.com/ruma/ruma?rev=4c00bd010dbdca6005bd599b52e90a0b7015d056#4c00bd010dbdca6005bd599b52e90a0b7015d056" dependencies = [ "as_variant", "assign", @@ -4774,7 +4775,7 @@ dependencies = [ [[package]] name = "ruma-common" version = "0.12.1" -source = "git+https://github.com/ruma/ruma?rev=b2542df2bbbdf09af0612c9f28bcfa5620e1911c#b2542df2bbbdf09af0612c9f28bcfa5620e1911c" +source = "git+https://github.com/ruma/ruma?rev=4c00bd010dbdca6005bd599b52e90a0b7015d056#4c00bd010dbdca6005bd599b52e90a0b7015d056" dependencies = [ "as_variant", "base64 0.21.7", @@ -4795,16 +4796,18 @@ dependencies = [ "serde_html_form", "serde_json", "thiserror", + "time", "tracing", "url", "uuid", + "web-time", "wildmatch", ] [[package]] name = "ruma-events" version = "0.27.11" -source = "git+https://github.com/ruma/ruma?rev=b2542df2bbbdf09af0612c9f28bcfa5620e1911c#b2542df2bbbdf09af0612c9f28bcfa5620e1911c" +source = "git+https://github.com/ruma/ruma?rev=4c00bd010dbdca6005bd599b52e90a0b7015d056#4c00bd010dbdca6005bd599b52e90a0b7015d056" dependencies = [ "as_variant", "indexmap 2.2.2", @@ -4828,7 +4831,7 @@ dependencies = [ [[package]] name = "ruma-federation-api" version = "0.8.0" -source = "git+https://github.com/ruma/ruma?rev=b2542df2bbbdf09af0612c9f28bcfa5620e1911c#b2542df2bbbdf09af0612c9f28bcfa5620e1911c" +source = "git+https://github.com/ruma/ruma?rev=4c00bd010dbdca6005bd599b52e90a0b7015d056#4c00bd010dbdca6005bd599b52e90a0b7015d056" dependencies = [ "js_int", "ruma-common", @@ -4840,7 +4843,7 @@ dependencies = [ [[package]] name = "ruma-html" version = "0.1.0" -source = "git+https://github.com/ruma/ruma?rev=b2542df2bbbdf09af0612c9f28bcfa5620e1911c#b2542df2bbbdf09af0612c9f28bcfa5620e1911c" +source = "git+https://github.com/ruma/ruma?rev=4c00bd010dbdca6005bd599b52e90a0b7015d056#4c00bd010dbdca6005bd599b52e90a0b7015d056" dependencies = [ "as_variant", "html5ever", @@ -4852,7 +4855,7 @@ dependencies = [ [[package]] name = "ruma-identifiers-validation" version = "0.9.3" -source = "git+https://github.com/ruma/ruma?rev=b2542df2bbbdf09af0612c9f28bcfa5620e1911c#b2542df2bbbdf09af0612c9f28bcfa5620e1911c" +source = "git+https://github.com/ruma/ruma?rev=4c00bd010dbdca6005bd599b52e90a0b7015d056#4c00bd010dbdca6005bd599b52e90a0b7015d056" dependencies = [ "js_int", "thiserror", @@ -4861,7 +4864,7 @@ dependencies = [ [[package]] name = "ruma-macros" version = "0.12.0" -source = "git+https://github.com/ruma/ruma?rev=b2542df2bbbdf09af0612c9f28bcfa5620e1911c#b2542df2bbbdf09af0612c9f28bcfa5620e1911c" +source = "git+https://github.com/ruma/ruma?rev=4c00bd010dbdca6005bd599b52e90a0b7015d056#4c00bd010dbdca6005bd599b52e90a0b7015d056" dependencies = [ "once_cell", "proc-macro-crate 2.0.2", @@ -4876,7 +4879,7 @@ dependencies = [ [[package]] name = "ruma-push-gateway-api" version = "0.8.0" -source = "git+https://github.com/ruma/ruma?rev=b2542df2bbbdf09af0612c9f28bcfa5620e1911c#b2542df2bbbdf09af0612c9f28bcfa5620e1911c" +source = "git+https://github.com/ruma/ruma?rev=4c00bd010dbdca6005bd599b52e90a0b7015d056#4c00bd010dbdca6005bd599b52e90a0b7015d056" dependencies = [ "js_int", "ruma-common", @@ -6520,9 +6523,9 @@ dependencies = [ [[package]] name = "web-time" -version = "1.0.0" +version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2ee269d72cc29bf77a2c4bc689cc750fb39f5cbd493d2205bbb3f5c7779cf7b0" +checksum = "5a6580f308b1fad9207618087a65c04e7a10bc77e02c8e84e9b00dd4b12fa0bb" dependencies = [ "js-sys", "wasm-bindgen", diff --git a/Cargo.toml b/Cargo.toml index 52d42de64..632f3a83e 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -39,7 +39,7 @@ futures-util = { version = "0.3.26", default-features = false, features = [ http = "0.2.6" imbl = "2.0.0" itertools = "0.12.0" -ruma = { git = "https://github.com/ruma/ruma", rev = "b2542df2bbbdf09af0612c9f28bcfa5620e1911c", features = [ +ruma = { git = "https://github.com/ruma/ruma", rev = "4c00bd010dbdca6005bd599b52e90a0b7015d056", features = [ "client-api-c", "compat-upload-signatures", "compat-user-id", @@ -47,7 +47,7 @@ ruma = { git = "https://github.com/ruma/ruma", rev = "b2542df2bbbdf09af0612c9f28 "compat-tag-info", "unstable-msc3401", ] } -ruma-common = { git = "https://github.com/ruma/ruma", rev = "b2542df2bbbdf09af0612c9f28bcfa5620e1911c" } +ruma-common = { git = "https://github.com/ruma/ruma", rev = "4c00bd010dbdca6005bd599b52e90a0b7015d056" } once_cell = "1.16.0" rand = "0.8.5" serde = "1.0.151" diff --git a/bindings/matrix-sdk-ffi/src/ruma.rs b/bindings/matrix-sdk-ffi/src/ruma.rs index fc85768e3..ab930fbe9 100644 --- a/bindings/matrix-sdk-ffi/src/ruma.rs +++ b/bindings/matrix-sdk-ffi/src/ruma.rs @@ -172,30 +172,38 @@ impl TryFrom for RumaMessageType { formatted: content.formatted.map(Into::into), })) } - MessageType::Image { content } => Self::Image( - RumaImageMessageEventContent::new(content.body, (*content.source).clone()) - .formatted(content.formatted.map(Into::into)) - .filename(content.filename) - .info(content.info.map(Into::into).map(Box::new)), - ), - MessageType::Audio { content } => Self::Audio( - RumaAudioMessageEventContent::new(content.body, (*content.source).clone()) - .formatted(content.formatted.map(Into::into)) - .filename(content.filename) - .info(content.info.map(Into::into).map(Box::new)), - ), - MessageType::Video { content } => Self::Video( - RumaVideoMessageEventContent::new(content.body, (*content.source).clone()) - .formatted(content.formatted.map(Into::into)) - .filename(content.filename) - .info(content.info.map(Into::into).map(Box::new)), - ), - MessageType::File { content } => Self::File( - RumaFileMessageEventContent::new(content.body, (*content.source).clone()) - .formatted(content.formatted.map(Into::into)) - .filename(content.filename) - .info(content.info.map(Into::into).map(Box::new)), - ), + MessageType::Image { content } => { + let mut event_content = + RumaImageMessageEventContent::new(content.body, (*content.source).clone()) + .info(content.info.map(Into::into).map(Box::new)); + event_content.formatted = content.formatted.map(Into::into); + event_content.filename = content.filename; + Self::Image(event_content) + } + MessageType::Audio { content } => { + let mut event_content = + RumaAudioMessageEventContent::new(content.body, (*content.source).clone()) + .info(content.info.map(Into::into).map(Box::new)); + event_content.formatted = content.formatted.map(Into::into); + event_content.filename = content.filename; + Self::Audio(event_content) + } + MessageType::Video { content } => { + let mut event_content = + RumaVideoMessageEventContent::new(content.body, (*content.source).clone()) + .info(content.info.map(Into::into).map(Box::new)); + event_content.formatted = content.formatted.map(Into::into); + event_content.filename = content.filename; + Self::Video(event_content) + } + MessageType::File { content } => { + let mut event_content = + RumaFileMessageEventContent::new(content.body, (*content.source).clone()) + .info(content.info.map(Into::into).map(Box::new)); + event_content.formatted = content.formatted.map(Into::into); + event_content.filename = content.filename; + Self::File(event_content) + } MessageType::Notice { content } => { Self::Notice(assign!(RumaNoticeMessageEventContent::plain(content.body), { formatted: content.formatted.map(Into::into), diff --git a/crates/matrix-sdk-base/Cargo.toml b/crates/matrix-sdk-base/Cargo.toml index 7e3281d0e..333fbc142 100644 --- a/crates/matrix-sdk-base/Cargo.toml +++ b/crates/matrix-sdk-base/Cargo.toml @@ -65,6 +65,7 @@ futures-executor = { workspace = true } http = { workspace = true } matrix-sdk-test = { workspace = true } stream_assert = { workspace = true } +web-time = "1.1.0" [target.'cfg(not(target_arch = "wasm32"))'.dev-dependencies] tokio = { workspace = true, features = ["rt-multi-thread", "macros"] } diff --git a/crates/matrix-sdk-base/src/rooms/normal.rs b/crates/matrix-sdk-base/src/rooms/normal.rs index d95a823de..81a7ec91e 100644 --- a/crates/matrix-sdk-base/src/rooms/normal.rs +++ b/crates/matrix-sdk-base/src/rooms/normal.rs @@ -1304,7 +1304,6 @@ mod tests { ops::{Not, Sub}, str::FromStr, sync::Arc, - time::{Duration, SystemTime}, }; use assign::assign; @@ -1334,6 +1333,7 @@ mod tests { }; use serde_json::json; use stream_assert::{assert_pending, assert_ready}; + use web_time::{Duration, SystemTime}; #[cfg(feature = "experimental-sliding-sync")] use super::SyncInfo; diff --git a/crates/matrix-sdk/src/http_client/mod.rs b/crates/matrix-sdk/src/http_client/mod.rs index 409ae5319..7d9d2f2d4 100644 --- a/crates/matrix-sdk/src/http_client/mod.rs +++ b/crates/matrix-sdk/src/http_client/mod.rs @@ -137,7 +137,10 @@ impl HttpClient { let auth_scheme = R::METADATA.authentication; match auth_scheme { - AuthScheme::AccessToken | AuthScheme::AccessTokenOptional | AuthScheme::None => {} + AuthScheme::AccessToken + | AuthScheme::AccessTokenOptional + | AuthScheme::AppserviceToken + | AuthScheme::None => {} AuthScheme::ServerSignatures => { return Err(HttpError::NotClientRequest); } diff --git a/crates/matrix-sdk/src/media.rs b/crates/matrix-sdk/src/media.rs index 708bbbf99..82f590a1a 100644 --- a/crates/matrix-sdk/src/media.rs +++ b/crates/matrix-sdk/src/media.rs @@ -475,18 +475,17 @@ impl Media { thumbnail_source, thumbnail_info, }); - MessageType::Image( - ImageMessageEventContent::plain(body.to_owned(), url) - .info(Box::new(info)) - .filename(filename) - .formatted(config.formatted_caption), - ) + let mut image_message_event_content = + ImageMessageEventContent::plain(body.to_owned(), url).info(Box::new(info)); + image_message_event_content.filename = filename; + image_message_event_content.formatted = config.formatted_caption; + MessageType::Image(image_message_event_content) } mime::AUDIO => { - let audio_message_event_content = - message::AudioMessageEventContent::plain(body.to_owned(), url) - .filename(filename) - .formatted(config.formatted_caption); + let mut audio_message_event_content = + message::AudioMessageEventContent::plain(body.to_owned(), url); + audio_message_event_content.filename = filename; + audio_message_event_content.formatted = config.formatted_caption; MessageType::Audio(update_audio_message_event( audio_message_event_content, content_type, @@ -499,12 +498,11 @@ impl Media { thumbnail_source, thumbnail_info }); - MessageType::Video( - VideoMessageEventContent::plain(body.to_owned(), url) - .info(Box::new(info)) - .filename(filename) - .formatted(config.formatted_caption), - ) + let mut video_message_event_content = + VideoMessageEventContent::plain(body.to_owned(), url).info(Box::new(info)); + video_message_event_content.filename = filename; + video_message_event_content.formatted = config.formatted_caption; + MessageType::Video(video_message_event_content) } _ => { let info = assign!(config.info.map(FileInfo::from).unwrap_or_default(), { @@ -512,12 +510,11 @@ impl Media { thumbnail_source, thumbnail_info }); - MessageType::File( - FileMessageEventContent::plain(body.to_owned(), url) - .info(Box::new(info)) - .filename(filename) - .formatted(config.formatted_caption), - ) + let mut file_message_event_content = + FileMessageEventContent::plain(body.to_owned(), url).info(Box::new(info)); + file_message_event_content.filename = filename; + file_message_event_content.formatted = config.formatted_caption; + MessageType::File(file_message_event_content) } }) }