From 191dc39acfe96e599d0b43f8d4c9084abb056df6 Mon Sep 17 00:00:00 2001 From: Felix Ableitner Date: Mon, 6 May 2024 11:44:22 +0200 Subject: [PATCH] Use skip_serializing_none for nodeinfo (fixes #4702) --- Cargo.lock | 1 + crates/routes/Cargo.toml | 1 + crates/routes/src/nodeinfo.rs | 7 ++++++- 3 files changed, 8 insertions(+), 1 deletion(-) diff --git a/Cargo.lock b/Cargo.lock index 78ab0e924..a1d73eda8 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2940,6 +2940,7 @@ dependencies = [ "reqwest-middleware", "rss", "serde", + "serde_with", "tokio", "tracing", "url", diff --git a/crates/routes/Cargo.toml b/crates/routes/Cargo.toml index 1403f92e7..178234ba5 100644 --- a/crates/routes/Cargo.toml +++ b/crates/routes/Cargo.toml @@ -34,4 +34,5 @@ once_cell = { workspace = true } tracing = { workspace = true } tokio = { workspace = true } urlencoding = { workspace = true } +serde_with.workspace = true rss = "2.0.7" diff --git a/crates/routes/src/nodeinfo.rs b/crates/routes/src/nodeinfo.rs index dbb2ef68a..f77cc0fe3 100644 --- a/crates/routes/src/nodeinfo.rs +++ b/crates/routes/src/nodeinfo.rs @@ -9,6 +9,7 @@ use lemmy_utils::{ VERSION, }; use serde::{Deserialize, Serialize}; +use serde_with::skip_serializing_none; use url::Url; pub fn config(cfg: &mut web::ServiceConfig) { @@ -44,7 +45,7 @@ async fn node_info(context: web::Data) -> Result, } +#[skip_serializing_none] #[derive(Serialize, Deserialize, Debug, Default)] #[serde(default)] pub struct NodeInfoSoftware { @@ -101,6 +104,7 @@ pub struct NodeInfoSoftware { pub version: Option, } +#[skip_serializing_none] #[derive(Serialize, Deserialize, Debug, Default)] #[serde(rename_all = "camelCase", default)] pub struct NodeInfoUsage { @@ -109,6 +113,7 @@ pub struct NodeInfoUsage { pub local_comments: Option, } +#[skip_serializing_none] #[derive(Serialize, Deserialize, Debug, Default)] #[serde(rename_all = "camelCase", default)] pub struct NodeInfoUsers {