]> Untitled Git - lemmy.git/commitdiff
Change NodeInfo `links` to an array
authorAlexander Batischev <eual.jp@gmail.com>
Sun, 21 Nov 2021 17:10:39 +0000 (20:10 +0300)
committerAlexander Batischev <eual.jp@gmail.com>
Sun, 21 Nov 2021 17:10:39 +0000 (20:10 +0300)
NodeInfo spec[1] says that _.well-known/nodeinfo_ is a JSON Resource
Descriptor (JRD) document. That is specified in RFC 7033, where ยง4.4[2]
mandates that `links` is an array.

1. https://nodeinfo.diaspora.software/protocol.html
2. https://datatracker.ietf.org/doc/html/rfc7033#section-4.4

crates/routes/src/nodeinfo.rs

index 9e327efaef56536cb0cbb4f185f40e835246dffe..b30b9f977dcb038aa71123dd5ead263e2bb9d35b 100644 (file)
@@ -17,13 +17,13 @@ async fn node_info_well_known(
   context: web::Data<LemmyContext>,
 ) -> Result<HttpResponse<Body>, LemmyError> {
   let node_info = NodeInfoWellKnown {
-    links: NodeInfoWellKnownLinks {
+    links: vec![NodeInfoWellKnownLinks {
       rel: Url::parse("http://nodeinfo.diaspora.software/ns/schema/2.0")?,
       href: Url::parse(&format!(
         "{}/nodeinfo/2.0.json",
         &context.settings().get_protocol_and_hostname(),
       ))?,
-    },
+    }],
   };
   Ok(HttpResponse::Ok().json(node_info))
 }
@@ -63,7 +63,7 @@ async fn node_info(context: web::Data<LemmyContext>) -> Result<HttpResponse, Err
 
 #[derive(Serialize, Deserialize, Debug)]
 struct NodeInfoWellKnown {
-  pub links: NodeInfoWellKnownLinks,
+  pub links: Vec<NodeInfoWellKnownLinks>,
 }
 
 #[derive(Serialize, Deserialize, Debug)]