From c45771d9e767b75d96ffec2bd384967647ceb083 Mon Sep 17 00:00:00 2001 From: Felix Ableitner Date: Wed, 10 Mar 2021 18:17:17 +0100 Subject: [PATCH] Add instance name and icon --- src/federated_instances.rs | 14 ++++++++++++++ src/main.rs | 4 ++++ 2 files changed, 18 insertions(+) diff --git a/src/federated_instances.rs b/src/federated_instances.rs index 9f0be83..b98d246 100644 --- a/src/federated_instances.rs +++ b/src/federated_instances.rs @@ -2,6 +2,7 @@ use serde::Deserialize; #[derive(Deserialize, Debug, Clone)] pub struct GetSiteResponse { + pub site_view: SiteView, pub online: usize, pub federated_instances: Option, } @@ -12,3 +13,16 @@ pub struct FederatedInstances { pub allowed: Option>, pub blocked: Option>, } + +#[derive(Deserialize, Debug, Clone)] +pub struct SiteView { + pub site: Site, + +} + +#[derive(Deserialize, Debug, Clone)] +pub struct Site { + pub name: String, + pub icon: String, + +} diff --git a/src/main.rs b/src/main.rs index 10ce7c4..b180fea 100644 --- a/src/main.rs +++ b/src/main.rs @@ -50,6 +50,8 @@ pub async fn main() -> Result<(), Error> { #[derive(Serialize, Clone)] struct InstanceDetails { domain: String, + name: String, + icon: String, online_users: i32, total_users: i64, users_active_halfyear: i64, @@ -70,6 +72,8 @@ async fn fetch_instance_details(domain: &str) -> Result Ok(InstanceDetails { domain: domain.to_owned(), + name: site_info.site_view.site.name, + icon: site_info.site_view.site.icon, online_users: site_info.online as i32, total_users: node_info.usage.users.total, users_active_halfyear: node_info.usage.users.active_halfyear,