forked from alemi/upub
feat: dump json to stdout after fetching
This commit is contained in:
parent
c9a20b4e65
commit
4d44688564
1 changed files with 3 additions and 5 deletions
|
@ -122,20 +122,16 @@ async fn main() {
|
||||||
|
|
||||||
|
|
||||||
async fn fetch(db: sea_orm::DatabaseConnection, domain: String, uri: String, save: bool) -> crate::Result<()> {
|
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)
|
let ctx = server::Context::new(db, domain)
|
||||||
.await.expect("failed creating server context");
|
.await.expect("failed creating server context");
|
||||||
|
|
||||||
let mut node = apb::Node::link(uri.to_string());
|
let mut node = apb::Node::link(uri.to_string());
|
||||||
tracing::info!("fetching object");
|
|
||||||
node.fetch(&ctx).await?;
|
node.fetch(&ctx).await?;
|
||||||
tracing::info!("fetched node");
|
|
||||||
|
|
||||||
let obj = node.get().expect("node still empty after fetch?");
|
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 {
|
if save {
|
||||||
match obj.base_type() {
|
match obj.base_type() {
|
||||||
Some(apb::BaseType::Object(apb::ObjectType::Actor(_))) => {
|
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(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue