From f66e0b812fb2b498fc31c8de7bc168d13b01ed3d Mon Sep 17 00:00:00 2001 From: silverpill Date: Fri, 24 Feb 2023 00:49:18 +0000 Subject: [PATCH] Make webfinger response compatible with GNU Social account lookup --- CHANGELOG.md | 1 + src/nodeinfo/views.rs | 2 +- src/webfinger/types.rs | 2 +- src/webfinger/views.rs | 12 +++++++++--- 4 files changed, 12 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 2d45658..b2d471d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -20,6 +20,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). ### Fixed - 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 diff --git a/src/nodeinfo/views.rs b/src/nodeinfo/views.rs index 018a2da..aedbb24 100644 --- a/src/nodeinfo/views.rs +++ b/src/nodeinfo/views.rs @@ -20,7 +20,7 @@ pub async fn get_nodeinfo( let nodeinfo_2_0_url = format!("{}/nodeinfo/2.0", config.instance_url()); let link = Link { rel: "http://nodeinfo.diaspora.software/ns/schema/2.0".to_string(), - link_type: None, + media_type: None, href: Some(nodeinfo_2_0_url), }; let jrd = JsonResourceDescriptor { diff --git a/src/webfinger/types.rs b/src/webfinger/types.rs index 3216dbd..d818711 100644 --- a/src/webfinger/types.rs +++ b/src/webfinger/types.rs @@ -60,7 +60,7 @@ pub struct Link { pub rel: String, #[serde(rename = "type", skip_serializing_if = "Option::is_none")] - pub link_type: Option, + pub media_type: Option, pub href: Option, } diff --git a/src/webfinger/views.rs b/src/webfinger/views.rs index 453b438..b48182e 100644 --- a/src/webfinger/views.rs +++ b/src/webfinger/views.rs @@ -57,14 +57,20 @@ async fn get_jrd( }; 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(), - link_type: Some(AP_MEDIA_TYPE.to_string()), + media_type: Some(AP_MEDIA_TYPE.to_string()), href: Some(actor_id), }; let jrd = JsonResourceDescriptor { subject: format!("acct:{}", actor_address), - links: vec![link], + links: vec![link_profile, link_actor], }; Ok(jrd) }