From 80571567e147bef58a86782e12193de1fc30cbd0 Mon Sep 17 00:00:00 2001 From: Nutomic Date: Thu, 23 Feb 2023 23:51:33 +0900 Subject: [PATCH] Add default attribute for webfinger properties (fixes #2756) (#2759) --- Cargo.lock | 1 + crates/utils/Cargo.toml | 4 ++++ crates/utils/src/lib.rs | 20 ++++++++++++++++++++ 3 files changed, 25 insertions(+) diff --git a/Cargo.lock b/Cargo.lock index de31dbf0..260b8c94 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2624,6 +2624,7 @@ dependencies = [ "percent-encoding", "rand 0.8.5", "regex", + "reqwest", "reqwest-middleware", "rosetta-build", "rosetta-i18n", diff --git a/crates/utils/Cargo.toml b/crates/utils/Cargo.toml index 21f92b11..9415ff6e 100644 --- a/crates/utils/Cargo.toml +++ b/crates/utils/Cargo.toml @@ -47,5 +47,9 @@ jsonwebtoken = "8.1.1" lettre = "0.10.1" comrak = { version = "0.14.0", default-features = false } +[dev-dependencies] +reqwest = { workspace = true } +tokio = { workspace = true, features = ["macros"] } + [build-dependencies] rosetta-build = "0.1.2" diff --git a/crates/utils/src/lib.rs b/crates/utils/src/lib.rs index 799d6994..cdc8c83a 100644 --- a/crates/utils/src/lib.rs +++ b/crates/utils/src/lib.rs @@ -37,6 +37,7 @@ pub struct WebfingerLink { #[serde(rename = "type")] pub kind: Option, pub href: Option, + #[serde(default)] pub properties: HashMap, } @@ -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::().await; + assert!(res.is_ok()); + } +} -- 2.44.1