From: Nutomic Date: Thu, 23 Feb 2023 14:51:33 +0000 (+0900) Subject: Add default attribute for webfinger properties (fixes #2756) (#2759) X-Git-Url: http://these/git/%22%7Burl%7D/%22https:/image.com/%7B%60%24%7BghostArchiveUrl%7D/%7Brss%7D?a=commitdiff_plain;h=80571567e147bef58a86782e12193de1fc30cbd0;p=lemmy.git Add default attribute for webfinger properties (fixes #2756) (#2759) --- 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()); + } +}