Add default attribute for webfinger properties (fixes #2756) (#2759)

This commit is contained in:
Nutomic 2023-02-23 23:51:33 +09:00 committed by GitHub
parent 155af88582
commit 80571567e1
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 25 additions and 0 deletions

1
Cargo.lock generated
View file

@ -2624,6 +2624,7 @@ dependencies = [
"percent-encoding", "percent-encoding",
"rand 0.8.5", "rand 0.8.5",
"regex", "regex",
"reqwest",
"reqwest-middleware", "reqwest-middleware",
"rosetta-build", "rosetta-build",
"rosetta-i18n", "rosetta-i18n",

View file

@ -47,5 +47,9 @@ jsonwebtoken = "8.1.1"
lettre = "0.10.1" lettre = "0.10.1"
comrak = { version = "0.14.0", default-features = false } comrak = { version = "0.14.0", default-features = false }
[dev-dependencies]
reqwest = { workspace = true }
tokio = { workspace = true, features = ["macros"] }
[build-dependencies] [build-dependencies]
rosetta-build = "0.1.2" rosetta-build = "0.1.2"

View file

@ -37,6 +37,7 @@ pub struct WebfingerLink {
#[serde(rename = "type")] #[serde(rename = "type")]
pub kind: Option<String>, pub kind: Option<String>,
pub href: Option<Url>, pub href: Option<Url>,
#[serde(default)]
pub properties: HashMap<String, String>, pub properties: HashMap<String, String>,
} }
@ -57,3 +58,22 @@ macro_rules! location_info {
) )
}; };
} }
#[cfg(test)]
mod tests {
use super::*;
use reqwest::Client;
#[tokio::test]
#[ignore]
async fn test_webfinger() {
let client = Client::default();
let fetch_url =
"https://kino.schuerz.at/.well-known/webfinger?resource=acct:h0e@kino.schuerz.at";
let response = client.get(fetch_url).send().await.unwrap();
let res = response.json::<WebfingerResponse>().await;
assert!(res.is_ok());
}
}