mirror of
https://github.com/LemmyNet/lemmy.git
synced 2025-01-07 07:35:25 +00:00
better webfinger handling
This commit is contained in:
parent
cabcf3877f
commit
88f9b14ff3
1 changed files with 17 additions and 13 deletions
|
@ -38,9 +38,9 @@ async fn get_webfinger_response(
|
|||
) -> Result<HttpResponse, LemmyError> {
|
||||
let name = extract_webfinger_name(&info.resource, &context)?;
|
||||
|
||||
let links = if name == context.domain() {
|
||||
let links = if name == context.settings().hostname {
|
||||
// webfinger response for instance actor (required for mastodon authorized fetch)
|
||||
let url = Url::parse(&format!("https://{name}"))?;
|
||||
let url = Url::parse(&context.settings().get_protocol_and_hostname())?;
|
||||
vec![webfinger_link_for_actor(Some(url), "none", &context)]
|
||||
} else {
|
||||
// webfinger response for user/community
|
||||
|
@ -69,19 +69,23 @@ async fn get_webfinger_response(
|
|||
}
|
||||
.into_iter()
|
||||
.flatten()
|
||||
.collect();
|
||||
.collect::<Vec<_>>();
|
||||
|
||||
let json = Webfinger {
|
||||
subject: info.resource.clone(),
|
||||
links,
|
||||
..Default::default()
|
||||
};
|
||||
if links.is_empty() {
|
||||
Ok(HttpResponse::NotFound().finish())
|
||||
} else {
|
||||
let json = Webfinger {
|
||||
subject: info.resource.clone(),
|
||||
links,
|
||||
..Default::default()
|
||||
};
|
||||
|
||||
Ok(
|
||||
HttpResponse::Ok()
|
||||
.content_type(&WEBFINGER_CONTENT_TYPE)
|
||||
.json(json),
|
||||
)
|
||||
Ok(
|
||||
HttpResponse::Ok()
|
||||
.content_type(&WEBFINGER_CONTENT_TYPE)
|
||||
.json(json),
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
fn webfinger_link_for_actor(
|
||||
|
|
Loading…
Reference in a new issue