asyncify from_activity calls (i.e.: block_on())
This commit is contained in:
parent
87ce3a7b51
commit
82088596a8
@ -21,6 +21,7 @@ use plume_common::{
|
|||||||
};
|
};
|
||||||
use serde_json;
|
use serde_json;
|
||||||
use std::collections::HashSet;
|
use std::collections::HashSet;
|
||||||
|
use tokio::runtime::Runtime;
|
||||||
|
|
||||||
pub type LicensedArticle = CustomObject<Licensed, Article>;
|
pub type LicensedArticle = CustomObject<Licensed, Article>;
|
||||||
|
|
||||||
@ -579,11 +580,14 @@ impl FromId<PlumeRocket> for Post {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
let cover = article
|
let image = article
|
||||||
.object_props
|
.object_props
|
||||||
.icon_object::<Image>()
|
.icon_object::<Image>()
|
||||||
.ok()
|
.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 title = article.object_props.name_string()?;
|
||||||
let post = Post::insert(
|
let post = Post::insert(
|
||||||
@ -699,17 +703,21 @@ impl FromId<PlumeRocket> for PostUpdate {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn from_activity(c: &PlumeRocket, updated: LicensedArticle) -> Result<Self> {
|
fn from_activity(c: &PlumeRocket, updated: LicensedArticle) -> Result<Self> {
|
||||||
|
let image = updated
|
||||||
|
.object
|
||||||
|
.object_props
|
||||||
|
.icon_object::<Image>()
|
||||||
|
.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 {
|
Ok(PostUpdate {
|
||||||
ap_url: updated.object.object_props.id_string()?,
|
ap_url: updated.object.object_props.id_string()?,
|
||||||
title: updated.object.object_props.name_string().ok(),
|
title: updated.object.object_props.name_string().ok(),
|
||||||
subtitle: updated.object.object_props.summary_string().ok(),
|
subtitle: updated.object.object_props.summary_string().ok(),
|
||||||
content: updated.object.object_props.content_string().ok(),
|
content: updated.object.object_props.content_string().ok(),
|
||||||
cover: updated
|
cover: cover,
|
||||||
.object
|
|
||||||
.object_props
|
|
||||||
.icon_object::<Image>()
|
|
||||||
.ok()
|
|
||||||
.and_then(|img| Media::from_activity(&c, &img).ok().map(|m| m.id)),
|
|
||||||
source: updated
|
source: updated
|
||||||
.object
|
.object
|
||||||
.ap_object_props
|
.ap_object_props
|
||||||
|
Loading…
Reference in New Issue
Block a user