feat: dump json to stdout after fetching

This commit is contained in:
əlemi 2024-04-13 22:17:35 +02:00
parent c9a20b4e65
commit 4d44688564
Signed by: alemi
GPG key ID: A4895B84D311642C

View file

@ -122,20 +122,16 @@ async fn main() {
async fn fetch(db: sea_orm::DatabaseConnection, domain: String, uri: String, save: bool) -> crate::Result<()> {
use apb::{Base, Object};
use apb::Base;
let ctx = server::Context::new(db, domain)
.await.expect("failed creating server context");
let mut node = apb::Node::link(uri.to_string());
tracing::info!("fetching object");
node.fetch(&ctx).await?;
tracing::info!("fetched node");
let obj = node.get().expect("node still empty after fetch?");
tracing::info!("fetched object:{}, name:{}", obj.id().unwrap_or(""), obj.name().unwrap_or(""));
if save {
match obj.base_type() {
Some(apb::BaseType::Object(apb::ObjectType::Actor(_))) => {
@ -159,5 +155,7 @@ async fn fetch(db: sea_orm::DatabaseConnection, domain: String, uri: String, sav
}
}
println!("{}", serde_json::to_string_pretty(&obj).unwrap());
Ok(())
}