Add instance name and icon

This commit is contained in:
Felix Ableitner 2021-03-10 18:17:17 +01:00
parent 9cbed8f2a9
commit c45771d9e7
2 changed files with 18 additions and 0 deletions

View file

@ -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<FederatedInstances>,
}
@ -12,3 +13,16 @@ pub struct FederatedInstances {
pub allowed: Option<Vec<String>>,
pub blocked: Option<Vec<String>>,
}
#[derive(Deserialize, Debug, Clone)]
pub struct SiteView {
pub site: Site,
}
#[derive(Deserialize, Debug, Clone)]
pub struct Site {
pub name: String,
pub icon: String,
}

View file

@ -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<InstanceDetails, Error>
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,