From bc95aa4efae30dee6bf2ab16f00ddaae8f3ead1f Mon Sep 17 00:00:00 2001 From: Natty Date: Sat, 22 Apr 2023 02:35:12 +0200 Subject: [PATCH] Fixed WebFinger hostnames --- src/webfinger.rs | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/src/webfinger.rs b/src/webfinger.rs index 894464c..6f51c40 100644 --- a/src/webfinger.rs +++ b/src/webfinger.rs @@ -40,12 +40,17 @@ pub async fn handle_webfinger( StatusCode::UNPROCESSABLE_ENTITY })?; - ck.get_user_by_tag(&tag.name, tag.host.as_deref()) - .await - .map_err(|e| { - error!("Data error: {e}"); - StatusCode::INTERNAL_SERVER_ERROR - })? + ck.get_user_by_tag( + &tag.name, + tag.host + .filter(|host| *host != config.networking.host) + .as_deref(), + ) + .await + .map_err(|e| { + error!("Data error: {e}"); + StatusCode::INTERNAL_SERVER_ERROR + })? } // Kinda a WebFingerSubject::Url(url) => ck.get_user_by_uri(&url).await.map_err(|e| { @@ -59,7 +64,10 @@ pub async fn handle_webfinger( } let user = user.unwrap(); - let tag = FediverseTag::from((&user.username, user.host.as_ref())); + let tag = FediverseTag::from(( + &user.username, + user.host.as_ref().or(Some(&config.networking.host)), + )); let mut links = Vec::new(); let mut aliases = Vec::new();