use crate::cli::{print_value, DaemonClient};
use anyhow::Result;
pub async fn online(client: &DaemonClient) -> Result<()> {
client.ensure_running().await?;
let resp = client.get("/presence/online").await?;
print_value(client.format(), &resp);
Ok(())
}
pub async fn foaf(client: &DaemonClient, ttl: u8, timeout_ms: u64) -> Result<()> {
client.ensure_running().await?;
let ttl_str = ttl.to_string();
let timeout_str = timeout_ms.to_string();
let resp = client
.get_query(
"/presence/foaf",
&[("ttl", &ttl_str), ("timeout_ms", &timeout_str)],
)
.await?;
print_value(client.format(), &resp);
Ok(())
}
pub async fn find(client: &DaemonClient, id: &str, ttl: u8, timeout_ms: u64) -> Result<()> {
client.ensure_running().await?;
let ttl_str = ttl.to_string();
let timeout_str = timeout_ms.to_string();
let resp = client
.get_query(
&format!("/presence/find/{id}"),
&[("ttl", &ttl_str), ("timeout_ms", &timeout_str)],
)
.await?;
print_value(client.format(), &resp);
Ok(())
}
pub async fn status(client: &DaemonClient, id: &str) -> Result<()> {
client.ensure_running().await?;
let resp = client.get(&format!("/presence/status/{id}")).await?;
print_value(client.format(), &resp);
Ok(())
}