appservice-api: Make the url field of Registration an Option

It was always possible to set it to `null`, according to the Matrix
spec.
This commit is contained in:
Kévin Commaille 2023-12-27 11:50:46 +01:00 committed by Kévin Commaille
parent 7c49b84e6d
commit 9a5142052c
3 changed files with 13 additions and 4 deletions

View File

@ -1,5 +1,10 @@
# [unreleased] # [unreleased]
Breaking changes:
* The `url` field of `Registration` is now an `Option<String>`. This should have
always been the case.
# 0.9.0 # 0.9.0
Improvements: Improvements:

View File

@ -74,7 +74,9 @@ pub struct Registration {
pub id: String, pub id: String,
/// The URL for the application service. /// The URL for the application service.
pub url: String, ///
/// Optionally set to `null` if no traffic is required.
pub url: Option<String>,
/// A unique token for application services to use to authenticate requests to Homeservers. /// A unique token for application services to use to authenticate requests to Homeservers.
pub as_token: String, pub as_token: String,
@ -112,7 +114,9 @@ pub struct RegistrationInit {
pub id: String, pub id: String,
/// The URL for the application service. /// The URL for the application service.
pub url: String, ///
/// Optionally set to `null` if no traffic is required.
pub url: Option<String>,
/// A unique token for application services to use to authenticate requests to Homeservers. /// A unique token for application services to use to authenticate requests to Homeservers.
pub as_token: String, pub as_token: String,

View File

@ -21,7 +21,7 @@ fn registration_deserialization() {
let observed: Registration = serde_yaml::from_str(registration_config).unwrap(); let observed: Registration = serde_yaml::from_str(registration_config).unwrap();
assert_eq!(observed.id, "IRC Bridge"); assert_eq!(observed.id, "IRC Bridge");
assert_eq!(observed.url, "http://127.0.0.1:1234"); assert_eq!(observed.url.unwrap(), "http://127.0.0.1:1234");
assert_eq!( assert_eq!(
observed.as_token, observed.as_token,
"30c05ae90a248a4188e620216fa72e349803310ec83e2a77b34fe90be6081f46" "30c05ae90a248a4188e620216fa72e349803310ec83e2a77b34fe90be6081f46"
@ -59,5 +59,5 @@ fn config_with_optional_url() {
rooms: [] rooms: []
"#; "#;
assert_matches!(serde_yaml::from_str(registration_config).unwrap(), Registration { url, .. }); assert_matches!(serde_yaml::from_str(registration_config).unwrap(), Registration { url, .. });
assert_eq!(url, "null"); assert_eq!(url, None);
} }