diff --git a/src/crawl.rs b/src/crawl.rs index a5ff501..f7833fd 100644 --- a/src/crawl.rs +++ b/src/crawl.rs @@ -50,6 +50,7 @@ pub async fn crawl( pub struct InstanceDetails { pub domain: String, pub name: String, + pub description: Option, pub version: String, pub icon: Option, pub online_users: i32, @@ -99,7 +100,7 @@ async fn fetch_instance_details(domain: &str) -> Result let node_info: NodeInfo = node_info.json().await?; let site_info_v2 = site_info_v2.json::().await.ok(); let site_info_v3 = site_info_v3.json::().await.ok(); - let site_info: GetSiteResponse = if let Some(site_info_v2) = site_info_v2 { + let mut site_info: GetSiteResponse = if let Some(site_info_v2) = site_info_v2 { site_info_v2 } else if let Some(site_info_v3) = site_info_v3 { site_info_v3 @@ -107,6 +108,12 @@ async fn fetch_instance_details(domain: &str) -> Result return Err(anyhow!("Failed to read site_info")); }; + if let Some(description) = &site_info.site_view.site.description { + if description.len() > 150 { + site_info.site_view.site.description = None; + } + } + let linked_instances = site_info .federated_instances .map(|f| f.linked) @@ -114,6 +121,7 @@ async fn fetch_instance_details(domain: &str) -> Result Ok(InstanceDetails { domain: domain.to_owned(), name: site_info.site_view.site.name, + description: site_info.site_view.site.description, version: node_info.software.version, icon: site_info.site_view.site.icon, online_users: site_info.online as i32, diff --git a/src/federated_instances.rs b/src/federated_instances.rs index fb0a83f..ea1948a 100644 --- a/src/federated_instances.rs +++ b/src/federated_instances.rs @@ -23,4 +23,5 @@ pub struct SiteView { pub struct Site { pub name: String, pub icon: Option, + pub description: Option, }