unroll filter_map() to easier .await
This commit is contained in:
parent
a508a4150c
commit
41f97b01f0
@ -1,3 +1,4 @@
|
|||||||
|
use activitypub::link;
|
||||||
use chrono::Utc;
|
use chrono::Utc;
|
||||||
use heck::{CamelCase, KebabCase};
|
use heck::{CamelCase, KebabCase};
|
||||||
use rocket::request::LenientForm;
|
use rocket::request::LenientForm;
|
||||||
@ -303,14 +304,16 @@ pub async fn update(
|
|||||||
.expect("post::update: update error");
|
.expect("post::update: update error");
|
||||||
|
|
||||||
if post.published {
|
if post.published {
|
||||||
post.update_mentions(
|
// NOTE: here we unroll a filter_map(), so we can use .await painlessly
|
||||||
&conn,
|
let mut filtered_mentions: Vec<link::Mention> = vec![];
|
||||||
mentions
|
for m in mentions.into_iter() {
|
||||||
.into_iter()
|
match Mention::build_activity(&rockets, &m).await {
|
||||||
.filter_map(|m| Mention::build_activity(&rockets, &m).await.ok())
|
Ok(m) => filtered_mentions.push(m),
|
||||||
.collect(),
|
Err(_) => {}
|
||||||
)
|
}
|
||||||
.expect("post::update: mentions error");
|
}
|
||||||
|
post.update_mentions(&conn, filtered_mentions)
|
||||||
|
.expect("post::update: mentions error");
|
||||||
}
|
}
|
||||||
|
|
||||||
let tags = form
|
let tags = form
|
||||||
|
Loading…
Reference in New Issue
Block a user