client-api: Don't require the failures field in the signatures upload response
The field is not marked as required in the spec[1] and at least one homeserver, namely Dendrite, omits the field if it's empty. [1]: https://spec.matrix.org/unstable/client-server-api/#post_matrixclientv3keyssignaturesupload
This commit is contained in:
parent
4d9f754657
commit
b8768c3f19
@ -1,5 +1,10 @@
|
|||||||
# [unreleased]
|
# [unreleased]
|
||||||
|
|
||||||
|
Bug fixes:
|
||||||
|
|
||||||
|
- Don't require the `failures` field in the
|
||||||
|
`ruma_client_api::keys::upload_signatures::Response` type.
|
||||||
|
|
||||||
Breaking changes:
|
Breaking changes:
|
||||||
|
|
||||||
- The conversion from `PushRule` to `ConditionalPushRule` is infallible since
|
- The conversion from `PushRule` to `ConditionalPushRule` is infallible since
|
||||||
|
@ -45,6 +45,7 @@ pub mod v3 {
|
|||||||
#[derive(Default)]
|
#[derive(Default)]
|
||||||
pub struct Response {
|
pub struct Response {
|
||||||
/// Signature processing failures.
|
/// Signature processing failures.
|
||||||
|
#[serde(default, skip_serializing_if = "BTreeMap::is_empty")]
|
||||||
pub failures: BTreeMap<OwnedUserId, BTreeMap<String, Failure>>,
|
pub failures: BTreeMap<OwnedUserId, BTreeMap<String, Failure>>,
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -117,14 +118,17 @@ pub mod v3 {
|
|||||||
_Custom(PrivOwnedStr),
|
_Custom(PrivOwnedStr),
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(all(test, feature = "client", feature = "compat-upload-signatures"))]
|
#[cfg(all(test, feature = "client"))]
|
||||||
mod tests {
|
mod tests {
|
||||||
use ruma_common::user_id;
|
use super::ResponseBody;
|
||||||
|
|
||||||
use super::{FailureErrorCode, ResponseBody};
|
|
||||||
|
|
||||||
|
#[cfg(feature = "compat-upload-signatures")]
|
||||||
#[test]
|
#[test]
|
||||||
fn deserialize_synapse_response() {
|
fn deserialize_synapse_response() {
|
||||||
|
use ruma_common::user_id;
|
||||||
|
|
||||||
|
use super::FailureErrorCode;
|
||||||
|
|
||||||
const JSON: &str = r#"{
|
const JSON: &str = r#"{
|
||||||
"failures": {
|
"failures": {
|
||||||
"@richvdh:sw1v.org": {
|
"@richvdh:sw1v.org": {
|
||||||
@ -142,6 +146,14 @@ pub mod v3 {
|
|||||||
assert_eq!(failure.errcode, FailureErrorCode::InvalidSignature);
|
assert_eq!(failure.errcode, FailureErrorCode::InvalidSignature);
|
||||||
assert_eq!(failure.error, "400: Invalid signature");
|
assert_eq!(failure.error, "400: Invalid signature");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn deserialize_empty_response() {
|
||||||
|
const JSON: &str = r#"{}"#;
|
||||||
|
|
||||||
|
let _parsed: ResponseBody = serde_json::from_str(JSON)
|
||||||
|
.expect("We should be able to deserialize an empty keys/signatures/upload");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user