client-api: Add a compat feature for Synapse's upload-signatures response
This commit is contained in:
parent
52aa539cf0
commit
bbdc0b68e8
@ -33,6 +33,10 @@ compat-unset-avatar = []
|
|||||||
# even if its value is an empty list.
|
# even if its value is an empty list.
|
||||||
compat-get-3pids = []
|
compat-get-3pids = []
|
||||||
|
|
||||||
|
# Accept `message` as an alias for `error` in `upload_signatures::v3::Failure`,
|
||||||
|
# since that's what Synapse sends.
|
||||||
|
compat-upload-signatures = []
|
||||||
|
|
||||||
unstable-exhaustive-types = ["ruma-common/unstable-exhaustive-types"]
|
unstable-exhaustive-types = ["ruma-common/unstable-exhaustive-types"]
|
||||||
unstable-msc2666 = []
|
unstable-msc2666 = []
|
||||||
unstable-msc2448 = []
|
unstable-msc2448 = []
|
||||||
|
@ -101,6 +101,7 @@ pub mod v3 {
|
|||||||
errcode: FailureErrorCode,
|
errcode: FailureErrorCode,
|
||||||
|
|
||||||
/// Human-readable error message.
|
/// Human-readable error message.
|
||||||
|
#[cfg_attr(feature = "compat-upload-signatures", serde(alias = "message"))]
|
||||||
error: String,
|
error: String,
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -116,6 +117,33 @@ pub mod v3 {
|
|||||||
#[doc(hidden)]
|
#[doc(hidden)]
|
||||||
_Custom(PrivOwnedStr),
|
_Custom(PrivOwnedStr),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cfg(all(test, feature = "client", feature = "compat-upload-signatures"))]
|
||||||
|
mod tests {
|
||||||
|
use ruma_common::user_id;
|
||||||
|
|
||||||
|
use super::{FailureErrorCode, ResponseBody};
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn deserialize_synapse_response() {
|
||||||
|
const JSON: &str = r#"{
|
||||||
|
"failures": {
|
||||||
|
"@richvdh:sw1v.org": {
|
||||||
|
"EOZDSWJVGZ": {
|
||||||
|
"status": 400,
|
||||||
|
"errcode": "M_INVALID_SIGNATURE",
|
||||||
|
"message": "400: Invalid signature"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}"#;
|
||||||
|
|
||||||
|
let parsed: ResponseBody = serde_json::from_str(JSON).unwrap();
|
||||||
|
let failure = &parsed.failures[user_id!("@richvdh:sw1v.org")]["EOZDSWJVGZ"];
|
||||||
|
assert_eq!(failure.errcode, FailureErrorCode::InvalidSignature);
|
||||||
|
assert_eq!(failure.error, "400: Invalid signature");
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
mod iter;
|
mod iter;
|
||||||
|
@ -123,6 +123,9 @@ compat-unset-avatar = ["ruma-client-api?/compat-unset-avatar"]
|
|||||||
# Always serialize the threepids response field in `get_3pids::v3::Response`,
|
# Always serialize the threepids response field in `get_3pids::v3::Response`,
|
||||||
# even if its value is an empty list.
|
# even if its value is an empty list.
|
||||||
compat-get-3pids = ["ruma-client-api?/compat-get-3pids"]
|
compat-get-3pids = ["ruma-client-api?/compat-get-3pids"]
|
||||||
|
# Accept `message` as an alias for `error` in `upload_signatures::v3::Failure`,
|
||||||
|
# since that's what Synapse sends.
|
||||||
|
compat-upload-signatures = ["ruma-client-api?/compat-upload-signatures"]
|
||||||
# Allow extra characters in signature IDs not allowed in the specification.
|
# Allow extra characters in signature IDs not allowed in the specification.
|
||||||
compat-signature-id = ["ruma-signatures?/compat-signature-id"]
|
compat-signature-id = ["ruma-signatures?/compat-signature-id"]
|
||||||
|
|
||||||
@ -192,6 +195,7 @@ unstable-unspecified = [
|
|||||||
# Private feature, only used in test / benchmarking code
|
# Private feature, only used in test / benchmarking code
|
||||||
__ci = [
|
__ci = [
|
||||||
"full",
|
"full",
|
||||||
|
"compat-upload-signatures",
|
||||||
"unstable-unspecified",
|
"unstable-unspecified",
|
||||||
"unstable-sanitize",
|
"unstable-sanitize",
|
||||||
"unstable-msc1767",
|
"unstable-msc1767",
|
||||||
|
Loading…
x
Reference in New Issue
Block a user