Make webfinger response compatible with GNU Social account lookup

This commit is contained in:
silverpill 2023-02-24 00:49:18 +00:00
parent 56e0ed8f5d
commit f66e0b812f
4 changed files with 12 additions and 5 deletions

View file

@ -20,6 +20,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
### Fixed ### Fixed
- Prevent `delete-extraneous-posts` command from removing locally-linked posts. - Prevent `delete-extraneous-posts` command from removing locally-linked posts.
- Make webfinger response compatible with GNU Social account lookup.
## [1.14.0] - 2023-02-22 ## [1.14.0] - 2023-02-22

View file

@ -20,7 +20,7 @@ pub async fn get_nodeinfo(
let nodeinfo_2_0_url = format!("{}/nodeinfo/2.0", config.instance_url()); let nodeinfo_2_0_url = format!("{}/nodeinfo/2.0", config.instance_url());
let link = Link { let link = Link {
rel: "http://nodeinfo.diaspora.software/ns/schema/2.0".to_string(), rel: "http://nodeinfo.diaspora.software/ns/schema/2.0".to_string(),
link_type: None, media_type: None,
href: Some(nodeinfo_2_0_url), href: Some(nodeinfo_2_0_url),
}; };
let jrd = JsonResourceDescriptor { let jrd = JsonResourceDescriptor {

View file

@ -60,7 +60,7 @@ pub struct Link {
pub rel: String, pub rel: String,
#[serde(rename = "type", skip_serializing_if = "Option::is_none")] #[serde(rename = "type", skip_serializing_if = "Option::is_none")]
pub link_type: Option<String>, pub media_type: Option<String>,
pub href: Option<String>, pub href: Option<String>,
} }

View file

@ -57,14 +57,20 @@ async fn get_jrd(
}; };
local_actor_id(&instance.url(), &actor_address.username) local_actor_id(&instance.url(), &actor_address.username)
}; };
let link = Link { // Required by GNU Social
let link_profile = Link {
rel: "http://webfinger.net/rel/profile-page".to_string(),
media_type: Some("text/html".to_string()),
href: Some(actor_id.clone()),
};
let link_actor = Link {
rel: "self".to_string(), rel: "self".to_string(),
link_type: Some(AP_MEDIA_TYPE.to_string()), media_type: Some(AP_MEDIA_TYPE.to_string()),
href: Some(actor_id), href: Some(actor_id),
}; };
let jrd = JsonResourceDescriptor { let jrd = JsonResourceDescriptor {
subject: format!("acct:{}", actor_address), subject: format!("acct:{}", actor_address),
links: vec![link], links: vec![link_profile, link_actor],
}; };
Ok(jrd) Ok(jrd)
} }