client-api: Fix thirdparty_id_creds according to clarification in spec
This commit is contained in:
parent
94dd352cc5
commit
edc7b97d05
@ -412,12 +412,8 @@ impl IncomingReCaptcha {
|
|||||||
#[serde(tag = "type", rename = "m.login.email.identity")]
|
#[serde(tag = "type", rename = "m.login.email.identity")]
|
||||||
pub struct EmailIdentity<'a> {
|
pub struct EmailIdentity<'a> {
|
||||||
/// Thirdparty identifier credentials.
|
/// Thirdparty identifier credentials.
|
||||||
#[serde(rename = "threepidCreds")]
|
#[serde(rename = "threepid_creds")]
|
||||||
#[cfg_attr(
|
pub thirdparty_id_creds: &'a ThirdpartyIdCredentials,
|
||||||
feature = "compat",
|
|
||||||
serde(alias = "threepid_creds", deserialize_with = "deserialize_thirdparty_id_creds")
|
|
||||||
)]
|
|
||||||
pub thirdparty_id_creds: &'a [ThirdpartyIdCredentials],
|
|
||||||
|
|
||||||
/// The value of the session key given by the homeserver, if any.
|
/// The value of the session key given by the homeserver, if any.
|
||||||
pub session: Option<&'a str>,
|
pub session: Option<&'a str>,
|
||||||
@ -443,12 +439,8 @@ impl IncomingEmailIdentity {
|
|||||||
#[serde(tag = "type", rename = "m.login.msisdn")]
|
#[serde(tag = "type", rename = "m.login.msisdn")]
|
||||||
pub struct Msisdn<'a> {
|
pub struct Msisdn<'a> {
|
||||||
/// Thirdparty identifier credentials.
|
/// Thirdparty identifier credentials.
|
||||||
#[serde(rename = "threepidCreds")]
|
#[serde(rename = "threepid_creds")]
|
||||||
#[cfg_attr(
|
pub thirdparty_id_creds: &'a ThirdpartyIdCredentials,
|
||||||
feature = "compat",
|
|
||||||
serde(alias = "threepid_creds", deserialize_with = "deserialize_thirdparty_id_creds")
|
|
||||||
)]
|
|
||||||
pub thirdparty_id_creds: &'a [ThirdpartyIdCredentials],
|
|
||||||
|
|
||||||
/// The value of the session key given by the homeserver, if any.
|
/// The value of the session key given by the homeserver, if any.
|
||||||
pub session: Option<&'a str>,
|
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<Vec<ThirdpartyIdCredentials>, D::Error>
|
|
||||||
where
|
|
||||||
D: Deserializer<'de>,
|
|
||||||
{
|
|
||||||
use de::value::{MapAccessDeserializer, SeqAccessDeserializer};
|
|
||||||
|
|
||||||
struct CredsVisitor;
|
|
||||||
|
|
||||||
impl<'de> de::Visitor<'de> for CredsVisitor {
|
|
||||||
type Value = Vec<ThirdpartyIdCredentials>;
|
|
||||||
|
|
||||||
fn expecting(&self, formatter: &mut fmt::Formatter<'_>) -> fmt::Result {
|
|
||||||
formatter.write_str("an array or object")
|
|
||||||
}
|
|
||||||
|
|
||||||
fn visit_seq<A>(self, seq: A) -> Result<Self::Value, A::Error>
|
|
||||||
where
|
|
||||||
A: de::SeqAccess<'de>,
|
|
||||||
{
|
|
||||||
<Vec<ThirdpartyIdCredentials>>::deserialize(SeqAccessDeserializer::new(seq))
|
|
||||||
}
|
|
||||||
|
|
||||||
fn visit_map<A>(self, map: A) -> Result<Self::Value, A::Error>
|
|
||||||
where
|
|
||||||
A: de::MapAccess<'de>,
|
|
||||||
{
|
|
||||||
let creds = ThirdpartyIdCredentials::deserialize(MapAccessDeserializer::new(map))?;
|
|
||||||
Ok(vec![creds])
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
deserializer.deserialize_any(CredsVisitor)
|
|
||||||
}
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user