mirror of
https://github.com/LemmyNet/lemmy.git
synced 2024-11-26 22:31:20 +00:00
parent
4597ea2017
commit
589d952a95
1 changed files with 14 additions and 6 deletions
|
@ -10,6 +10,7 @@ use crate::{
|
||||||
};
|
};
|
||||||
use activitystreams_kinds::collection::OrderedCollectionType;
|
use activitystreams_kinds::collection::OrderedCollectionType;
|
||||||
use chrono::NaiveDateTime;
|
use chrono::NaiveDateTime;
|
||||||
|
use futures::future::join_all;
|
||||||
use lemmy_api_common::blocking;
|
use lemmy_api_common::blocking;
|
||||||
use lemmy_apub_lib::{
|
use lemmy_apub_lib::{
|
||||||
data::Data,
|
data::Data,
|
||||||
|
@ -97,7 +98,7 @@ impl ApubObject for ApubCommunityOutbox {
|
||||||
async fn from_apub(
|
async fn from_apub(
|
||||||
apub: Self::ApubType,
|
apub: Self::ApubType,
|
||||||
data: &Self::DataType,
|
data: &Self::DataType,
|
||||||
request_counter: &mut i32,
|
_request_counter: &mut i32,
|
||||||
) -> Result<Self, LemmyError> {
|
) -> Result<Self, LemmyError> {
|
||||||
let mut outbox_activities = apub.ordered_items;
|
let mut outbox_activities = apub.ordered_items;
|
||||||
if outbox_activities.len() > 20 {
|
if outbox_activities.len() > 20 {
|
||||||
|
@ -108,12 +109,19 @@ impl ApubObject for ApubCommunityOutbox {
|
||||||
// Lemmy versions, or from other software which we cant parse. In that case, we simply skip the
|
// Lemmy versions, or from other software which we cant parse. In that case, we simply skip the
|
||||||
// item and only parse the ones that work.
|
// item and only parse the ones that work.
|
||||||
let data = Data::new(data.1.clone());
|
let data = Data::new(data.1.clone());
|
||||||
for activity in outbox_activities {
|
// process items in parallel, to avoid long delay from fetch_site_metadata() and other processing
|
||||||
let verify = activity.verify(&data, request_counter).await;
|
join_all(outbox_activities.into_iter().map(|activity| {
|
||||||
if verify.is_ok() {
|
async {
|
||||||
activity.receive(&data, request_counter).await.ok();
|
// use separate request counter for each item, otherwise there will be problems with
|
||||||
|
// parallel processing
|
||||||
|
let request_counter = &mut 0;
|
||||||
|
let verify = activity.verify(&data, request_counter).await;
|
||||||
|
if verify.is_ok() {
|
||||||
|
activity.receive(&data, request_counter).await.ok();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}))
|
||||||
|
.await;
|
||||||
|
|
||||||
// This return value is unused, so just set an empty vec
|
// This return value is unused, so just set an empty vec
|
||||||
Ok(ApubCommunityOutbox(Vec::new()))
|
Ok(ApubCommunityOutbox(Vec::new()))
|
||||||
|
|
Loading…
Reference in a new issue