From 9f8cdecae62377f58317793f06430a0aff09b8b4 Mon Sep 17 00:00:00 2001 From: Jonas Platte Date: Sun, 29 Sep 2024 10:42:39 +0200 Subject: [PATCH 1/2] Upgrade outdated dependencies --- crates/ruma-html/Cargo.toml | 2 +- crates/ruma-html/src/html.rs | 1 + crates/ruma-state-res/Cargo.toml | 2 +- xtask/Cargo.toml | 2 +- xtask/src/cargo.rs | 8 ++++---- 5 files changed, 8 insertions(+), 7 deletions(-) diff --git a/crates/ruma-html/Cargo.toml b/crates/ruma-html/Cargo.toml index 982c75eb..3d40384a 100644 --- a/crates/ruma-html/Cargo.toml +++ b/crates/ruma-html/Cargo.toml @@ -18,7 +18,7 @@ matrix = ["dep:ruma-common"] [dependencies] as_variant = { workspace = true } -html5ever = "0.28.0" +html5ever = "0.29.0" phf = { version = "0.11.1", features = ["macros"] } ruma-common = { workspace = true, optional = true } tracing = { workspace = true, features = ["attributes"] } diff --git a/crates/ruma-html/src/html.rs b/crates/ruma-html/src/html.rs index a0f315d0..3c4a6903 100644 --- a/crates/ruma-html/src/html.rs +++ b/crates/ruma-html/src/html.rs @@ -100,6 +100,7 @@ impl Default for Html { impl TreeSink for Html { type Handle = NodeRef; type Output = Self; + type ElemName<'a> = html5ever::ExpandedName<'a>; fn finish(self) -> Self::Output { self diff --git a/crates/ruma-state-res/Cargo.toml b/crates/ruma-state-res/Cargo.toml index 0b6b7744..495110bc 100644 --- a/crates/ruma-state-res/Cargo.toml +++ b/crates/ruma-state-res/Cargo.toml @@ -18,7 +18,7 @@ all-features = true unstable-exhaustive-types = [] [dependencies] -itertools = "0.12.1" +itertools = "0.13.0" js_int = { workspace = true } ruma-common = { workspace = true } ruma-events = { workspace = true } diff --git a/xtask/Cargo.toml b/xtask/Cargo.toml index d97ef4e4..63b03415 100644 --- a/xtask/Cargo.toml +++ b/xtask/Cargo.toml @@ -15,7 +15,7 @@ semver = { version = "1.0.6", features = ["serde"], optional = true } serde = { workspace = true } serde_json = { workspace = true } toml = { version = "0.8.2", default-features = false, features = ["parse"] } -toml_edit = { version = "0.20.2", optional = true } +toml_edit = { version = "0.22.22", optional = true } xshell = "0.1.17" [lints] diff --git a/xtask/src/cargo.rs b/xtask/src/cargo.rs index 8fd21c75..755d6746 100644 --- a/xtask/src/cargo.rs +++ b/xtask/src/cargo.rs @@ -7,7 +7,7 @@ use reqwest::blocking::Client; use semver::Version; use serde::{de::IgnoredAny, Deserialize}; #[cfg(feature = "default")] -use toml_edit::{value, Document}; +use toml_edit::{value, DocumentMut}; #[cfg(feature = "default")] use xshell::{cmd, pushd, read_file, write_file}; @@ -78,7 +78,7 @@ impl Package { println!("Updating {} to version {version}…", self.name); if !dry_run { - let mut document = read_file(&self.manifest_path)?.parse::()?; + let mut document = read_file(&self.manifest_path)?.parse::()?; document["package"]["version"] = value(version.to_string()); @@ -101,7 +101,7 @@ impl Package { println!("Updating dependency in {} crate…", package.name); if !dry_run { - let mut document = read_file(&package.manifest_path)?.parse::()?; + let mut document = read_file(&package.manifest_path)?.parse::()?; let version = if !self.version.pre.is_empty() { format!("={}", self.version) @@ -124,7 +124,7 @@ impl Package { } } else { let workspace_manifest_path = metadata.workspace_root.join("Cargo.toml"); - let mut document = read_file(&workspace_manifest_path)?.parse::()?; + let mut document = read_file(&workspace_manifest_path)?.parse::()?; let workspace_deps = &mut document["workspace"]["dependencies"]; println!("Updating workspace dependency…"); From a9267360cb37e664410c175aaa9ece85c3b0e269 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?K=C3=A9vin=20Commaille?= Date: Sun, 29 Sep 2024 10:37:29 +0200 Subject: [PATCH 2/2] client-api: Add support for account locking According to MSC3939. --- crates/ruma-client-api/CHANGELOG.md | 1 + crates/ruma-client-api/src/error.rs | 28 +++++++++++++++++++ .../ruma-client-api/src/error/kind_serde.rs | 4 ++- 3 files changed, 32 insertions(+), 1 deletion(-) diff --git a/crates/ruma-client-api/CHANGELOG.md b/crates/ruma-client-api/CHANGELOG.md index 580b1a3e..9dd39e5c 100644 --- a/crates/ruma-client-api/CHANGELOG.md +++ b/crates/ruma-client-api/CHANGELOG.md @@ -36,6 +36,7 @@ Improvements: - This is a breaking change, but only for users of `unstable-msc3575` - Add the `get_login_token` field to `Capabilities`, according to a clarification in the spec. +- Add support for account locking, according to MSC3939. Bug fixes: diff --git a/crates/ruma-client-api/src/error.rs b/crates/ruma-client-api/src/error.rs index 7d2ddeb6..ee064fe2 100644 --- a/crates/ruma-client-api/src/error.rs +++ b/crates/ruma-client-api/src/error.rs @@ -204,6 +204,9 @@ pub enum ErrorKind { #[cfg(feature = "unstable-msc3843")] Unactionable, + /// M_USER_LOCKED + UserLocked, + #[doc(hidden)] _Custom { errcode: PrivOwnedStr, extra: Extra }, } @@ -280,6 +283,7 @@ impl AsRef for ErrorKind { Self::WrongRoomKeysVersion { .. } => "M_WRONG_ROOM_KEYS_VERSION", #[cfg(feature = "unstable-msc3843")] Self::Unactionable => "M_UNACTIONABLE", + Self::UserLocked => "M_USER_LOCKED", Self::_Custom { errcode, .. } => &errcode.0, } } @@ -927,4 +931,28 @@ mod tests { }) ); } + + #[test] + fn serialize_user_locked() { + let error = Error::new( + http::StatusCode::UNAUTHORIZED, + ErrorBody::Standard { + kind: ErrorKind::UserLocked, + message: "This account has been locked".to_owned(), + }, + ); + + let response = error.try_into_http_response::>().unwrap(); + + assert_eq!(response.status(), http::StatusCode::UNAUTHORIZED); + let json_body: JsonValue = from_json_slice(response.body()).unwrap(); + assert_eq!( + json_body, + json!({ + "errcode": "M_USER_LOCKED", + "error": "This account has been locked", + "soft_logout": true, + }) + ); + } } diff --git a/crates/ruma-client-api/src/error/kind_serde.rs b/crates/ruma-client-api/src/error/kind_serde.rs index 5121b2f5..4ad4c48c 100644 --- a/crates/ruma-client-api/src/error/kind_serde.rs +++ b/crates/ruma-client-api/src/error/kind_serde.rs @@ -252,6 +252,7 @@ impl<'de> Visitor<'de> for ErrorKindVisitor { }, #[cfg(feature = "unstable-msc3843")] ErrCode::Unactionable => ErrorKind::Unactionable, + ErrCode::UserLocked => ErrorKind::UserLocked, ErrCode::_Custom(errcode) => ErrorKind::_Custom { errcode, extra }, }) } @@ -310,6 +311,7 @@ enum ErrCode { WrongRoomKeysVersion, #[cfg(feature = "unstable-msc3843")] Unactionable, + UserLocked, _Custom(PrivOwnedStr), } @@ -330,7 +332,7 @@ impl Serialize for ErrorKind { let mut st = serializer.serialize_map(None)?; st.serialize_entry("errcode", self.as_ref())?; match self { - Self::UnknownToken { soft_logout: true } => { + Self::UnknownToken { soft_logout: true } | Self::UserLocked => { st.serialize_entry("soft_logout", &true)?; } Self::LimitExceeded { retry_after: Some(RetryAfter::Delay(duration)) } => {