Skip to content

Commit

Permalink
Use skip_serializing_none for webfinger (fixes #4702)
Browse files Browse the repository at this point in the history
  • Loading branch information
Nutomic committed May 6, 2024
1 parent b152be7 commit c7b606f
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 1 deletion.
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions crates/routes/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
7 changes: 6 additions & 1 deletion crates/routes/src/nodeinfo.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -44,7 +45,7 @@ async fn node_info(context: web::Data<LemmyContext>) -> Result<HttpResponse, Err
.ok_or(ErrorBadRequest(LemmyError::from(anyhow!("not_found"))))?;

let protocols = if site_view.local_site.federation_enabled {
Some(vec!["activitypub".to_string()])
None
} else {
None
};
Expand Down Expand Up @@ -84,6 +85,7 @@ struct NodeInfoWellKnownLinks {
pub href: Url,
}

#[skip_serializing_none]
#[derive(Serialize, Deserialize, Debug, Default)]
#[serde(rename_all = "camelCase", default)]
pub struct NodeInfo {
Expand All @@ -94,13 +96,15 @@ pub struct NodeInfo {
pub open_registrations: Option<bool>,
}

#[skip_serializing_none]
#[derive(Serialize, Deserialize, Debug, Default)]
#[serde(default)]
pub struct NodeInfoSoftware {
pub name: Option<String>,
pub version: Option<String>,
}

#[skip_serializing_none]
#[derive(Serialize, Deserialize, Debug, Default)]
#[serde(rename_all = "camelCase", default)]
pub struct NodeInfoUsage {
Expand All @@ -109,6 +113,7 @@ pub struct NodeInfoUsage {
pub local_comments: Option<i64>,
}

#[skip_serializing_none]
#[derive(Serialize, Deserialize, Debug, Default)]
#[serde(rename_all = "camelCase", default)]
pub struct NodeInfoUsers {
Expand Down

0 comments on commit c7b606f

Please sign in to comment.