diff --git a/CHANGELOG.md b/CHANGELOG.md index 0ca37c3..4b6f4a5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,19 @@ # Changelog +## [0.4.5] — 2026-07-16 + +### Bug fixes + +- Remove invalid `$schema` field from NodeInfo 2.0 response — the field is not allowed by the NodeInfo 2.0 schema (`additionalProperties: false`) +- Add missing required `services` and `metadata` fields to NodeInfo 2.0 response + +### New features + +- `FederationData::with_nodeinfo_services(inbound, outbound)` — configure NodeInfo `services.inbound`/`services.outbound` +- `FederationData::with_nodeinfo_metadata(value)` — set arbitrary NodeInfo `metadata` + +--- + ## [0.4.4] — 2026-07-11 ### Bug fixes diff --git a/Cargo.lock b/Cargo.lock index c6aaeb9..880f518 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1368,7 +1368,7 @@ dependencies = [ [[package]] name = "k-ap" -version = "0.4.4" +version = "0.4.5" dependencies = [ "activitypub_federation", "anyhow", diff --git a/Cargo.toml b/Cargo.toml index aa09961..bf5c440 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "k-ap" -version = "0.4.4" +version = "0.4.5" edition = "2024" description = "Generic ActivityPub protocol layer" license = "MIT" diff --git a/src/data.rs b/src/data.rs index 0ba94b3..563550e 100644 --- a/src/data.rs +++ b/src/data.rs @@ -71,6 +71,9 @@ pub struct FederationData { pub(crate) software_name: String, pub(crate) event_publisher: Option>, pub(crate) actor_cache_ttl: std::time::Duration, + pub(crate) nodeinfo_services_inbound: Vec, + pub(crate) nodeinfo_services_outbound: Vec, + pub(crate) nodeinfo_metadata: serde_json::Value, } impl FederationData { @@ -110,6 +113,20 @@ impl FederationData { software_name, event_publisher, actor_cache_ttl, + nodeinfo_services_inbound: vec![], + nodeinfo_services_outbound: vec![], + nodeinfo_metadata: serde_json::json!({}), } } + + pub fn with_nodeinfo_services(mut self, inbound: Vec, outbound: Vec) -> Self { + self.nodeinfo_services_inbound = inbound; + self.nodeinfo_services_outbound = outbound; + self + } + + pub fn with_nodeinfo_metadata(mut self, metadata: serde_json::Value) -> Self { + self.nodeinfo_metadata = metadata; + self + } } diff --git a/src/nodeinfo.rs b/src/nodeinfo.rs index d8dc6c2..d52045a 100644 --- a/src/nodeinfo.rs +++ b/src/nodeinfo.rs @@ -6,7 +6,6 @@ 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 { @@ -37,16 +36,22 @@ pub struct NodeInfoUsers { pub total: usize, } +#[derive(Serialize)] +pub struct NodeInfoServices { + pub inbound: Vec, + pub outbound: Vec, +} + #[derive(Serialize)] #[serde(rename_all = "camelCase")] pub struct NodeInfo { - #[serde(rename = "$schema")] - pub schema: String, pub version: String, pub software: NodeInfoSoftware, pub protocols: Vec, - pub usage: NodeInfoUsage, + pub services: NodeInfoServices, pub open_registrations: bool, + pub usage: NodeInfoUsage, + pub metadata: serde_json::Value, } pub async fn nodeinfo_well_known_handler( @@ -66,18 +71,22 @@ pub async fn nodeinfo_handler(data: Data) -> Result