Work around a difficult lifetime interaction between closures and async blocks.

This commit is contained in:
Jeb Rosen 2020-05-25 12:11:14 -07:00
parent e322d9509a
commit 4f904b7ac7

View file

@ -17,7 +17,6 @@ use activitypub::{
}; };
use chrono::{self, NaiveDateTime}; use chrono::{self, NaiveDateTime};
use diesel::{self, ExpressionMethods, QueryDsl, RunQueryDsl, SaveChangesDsl}; use diesel::{self, ExpressionMethods, QueryDsl, RunQueryDsl, SaveChangesDsl};
use futures::stream::{self, StreamExt};
use plume_common::{ use plume_common::{
activity_pub::{ activity_pub::{
inbox::{AsActor, AsObject, FromId}, inbox::{AsActor, AsObject, FromId},
@ -131,12 +130,16 @@ impl Comment {
.set_published_string(chrono::Utc::now().to_rfc3339())?; .set_published_string(chrono::Utc::now().to_rfc3339())?;
note.object_props.set_attributed_to_link(author.into_id())?; note.object_props.set_attributed_to_link(author.into_id())?;
note.object_props.set_to_link_vec(to)?; note.object_props.set_to_link_vec(to)?;
note.object_props.set_tag_link_vec(
stream::iter(mentions) let mut tag_link_vec = vec![];
.filter_map(|m| async move { Mention::build_activity(c, &m).await.ok() }) let mut iter = mentions.into_iter();
.collect::<Vec<link::Mention>>() while let Some(m) = iter.next() {
.await, if let Ok(a) = Mention::build_activity(c, &m).await {
)?; tag_link_vec.push(a);
}
}
note.object_props.set_tag_link_vec(tag_link_vec)?;
Ok(note) Ok(note)
} }