From edc7b97d0583a0447b49aaa02c90ba13b45ea8da Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?K=C3=A9vin=20Commaille?= <76261501+zecakeh@users.noreply.github.com> Date: Wed, 23 Feb 2022 13:29:49 +0100 Subject: [PATCH] client-api: Fix thirdparty_id_creds according to clarification in spec --- crates/ruma-client-api/src/uiaa.rs | 53 +++--------------------------- 1 file changed, 4 insertions(+), 49 deletions(-) diff --git a/crates/ruma-client-api/src/uiaa.rs b/crates/ruma-client-api/src/uiaa.rs index 26375ea2..bf759747 100644 --- a/crates/ruma-client-api/src/uiaa.rs +++ b/crates/ruma-client-api/src/uiaa.rs @@ -412,12 +412,8 @@ impl IncomingReCaptcha { #[serde(tag = "type", rename = "m.login.email.identity")] pub struct EmailIdentity<'a> { /// Thirdparty identifier credentials. - #[serde(rename = "threepidCreds")] - #[cfg_attr( - feature = "compat", - serde(alias = "threepid_creds", deserialize_with = "deserialize_thirdparty_id_creds") - )] - pub thirdparty_id_creds: &'a [ThirdpartyIdCredentials], + #[serde(rename = "threepid_creds")] + pub thirdparty_id_creds: &'a ThirdpartyIdCredentials, /// The value of the session key given by the homeserver, if any. pub session: Option<&'a str>, @@ -443,12 +439,8 @@ impl IncomingEmailIdentity { #[serde(tag = "type", rename = "m.login.msisdn")] pub struct Msisdn<'a> { /// Thirdparty identifier credentials. - #[serde(rename = "threepidCreds")] - #[cfg_attr( - feature = "compat", - serde(alias = "threepid_creds", deserialize_with = "deserialize_thirdparty_id_creds") - )] - pub thirdparty_id_creds: &'a [ThirdpartyIdCredentials], + #[serde(rename = "threepid_creds")] + pub thirdparty_id_creds: &'a ThirdpartyIdCredentials, /// The value of the session key given by the homeserver, if any. pub session: Option<&'a str>, @@ -746,40 +738,3 @@ impl OutgoingResponse for UiaaResponse { } } } - -#[cfg(feature = "compat")] -fn deserialize_thirdparty_id_creds<'de, D>( - deserializer: D, -) -> Result, D::Error> -where - D: Deserializer<'de>, -{ - use de::value::{MapAccessDeserializer, SeqAccessDeserializer}; - - struct CredsVisitor; - - impl<'de> de::Visitor<'de> for CredsVisitor { - type Value = Vec; - - fn expecting(&self, formatter: &mut fmt::Formatter<'_>) -> fmt::Result { - formatter.write_str("an array or object") - } - - fn visit_seq(self, seq: A) -> Result - where - A: de::SeqAccess<'de>, - { - >::deserialize(SeqAccessDeserializer::new(seq)) - } - - fn visit_map(self, map: A) -> Result - where - A: de::MapAccess<'de>, - { - let creds = ThirdpartyIdCredentials::deserialize(MapAccessDeserializer::new(map))?; - Ok(vec![creds]) - } - } - - deserializer.deserialize_any(CredsVisitor) -}