diff --git a/plume-models/src/posts.rs b/plume-models/src/posts.rs index 73c0c915..b562fe4b 100644 --- a/plume-models/src/posts.rs +++ b/plume-models/src/posts.rs @@ -21,6 +21,7 @@ use plume_common::{ }; use serde_json; use std::collections::HashSet; +use tokio::runtime::Runtime; pub type LicensedArticle = CustomObject; @@ -579,11 +580,14 @@ impl FromId for Post { } }); - let cover = article + let image = article .object_props .icon_object::() .ok() - .and_then(|img| Media::from_activity(&c, &img).ok().map(|m| m.id)); + .unwrap(); + + let mut r = Runtime::new().unwrap(); + let cover = Some(r.block_on(async {Media::from_activity(&c, &image).await.ok().unwrap().id})); let title = article.object_props.name_string()?; let post = Post::insert( @@ -699,17 +703,21 @@ impl FromId for PostUpdate { } fn from_activity(c: &PlumeRocket, updated: LicensedArticle) -> Result { + let image = updated + .object + .object_props + .icon_object::() + .ok() + .unwrap(); + let mut r = Runtime::new().unwrap(); + let cover = Some(r.block_on(async {Media::from_activity(&c, &image).await.ok().unwrap().id})); + Ok(PostUpdate { ap_url: updated.object.object_props.id_string()?, title: updated.object.object_props.name_string().ok(), subtitle: updated.object.object_props.summary_string().ok(), content: updated.object.object_props.content_string().ok(), - cover: updated - .object - .object_props - .icon_object::() - .ok() - .and_then(|img| Media::from_activity(&c, &img).ok().map(|m| m.id)), + cover: cover, source: updated .object .ap_object_props