feat: update NodeInfo 2.0 response to include $schema field and bump version to 0.4.3
Some checks failed
CI / fmt (push) Successful in 31s
CI / test (push) Has been cancelled
CI / clippy (push) Has been cancelled

This commit is contained in:
2026-07-11 10:18:18 +02:00
parent 902d38cc76
commit 997047fdbd
5 changed files with 19 additions and 2 deletions

View File

@@ -6,6 +6,7 @@ use crate::data::FederationData;
use crate::error::Error;
const NODEINFO_2_0_REL: &str = "http://nodeinfo.diaspora.software/ns/schema/2.0";
const NODEINFO_2_0_SCHEMA: &str = "http://nodeinfo.diaspora.software/ns/schema/2.0#";
#[derive(Serialize)]
pub struct NodeInfoWellKnown {
@@ -39,6 +40,8 @@ pub struct NodeInfoUsers {
#[derive(Serialize)]
#[serde(rename_all = "camelCase")]
pub struct NodeInfo {
#[serde(rename = "$schema")]
pub schema: String,
pub version: String,
pub software: NodeInfoSoftware,
pub protocols: Vec<String>,
@@ -63,6 +66,7 @@ pub async fn nodeinfo_handler(data: Data<FederationData>) -> Result<Json<NodeInf
let local_posts = data.content_reader.count_local_posts().await.unwrap_or(0);
Ok(Json(NodeInfo {
schema: NODEINFO_2_0_SCHEMA.to_string(),
version: "2.0".to_string(),
software: NodeInfoSoftware {
name: data.software_name.clone(),

View File

@@ -19,6 +19,7 @@ fn nodeinfo_well_known_serializes_correctly() {
#[test]
fn nodeinfo_serializes_camel_case() {
let doc = NodeInfo {
schema: "http://nodeinfo.diaspora.software/ns/schema/2.0#".to_string(),
version: "2.0".to_string(),
software: NodeInfoSoftware {
name: "my-app".to_string(),
@@ -32,6 +33,10 @@ fn nodeinfo_serializes_camel_case() {
open_registrations: false,
};
let json = serde_json::to_value(&doc).unwrap();
assert_eq!(
json["$schema"],
"http://nodeinfo.diaspora.software/ns/schema/2.0#"
);
assert_eq!(json["version"], "2.0");
assert_eq!(json["software"]["name"], "my-app");
assert_eq!(json["usage"]["users"]["total"], 3);