diff --git a/src/backend/federation/activities/update_remote_article.rs b/src/backend/federation/activities/update_remote_article.rs index a869a64..c73802a 100644 --- a/src/backend/federation/activities/update_remote_article.rs +++ b/src/backend/federation/activities/update_remote_article.rs @@ -80,7 +80,7 @@ impl ActivityHandler for UpdateRemoteArticle { Ok(()) } - /// Received on article origin instances + /// Received on article origin instance async fn receive(self, data: &Data) -> Result<(), Self::Error> { let local_article = DbArticle::read_from_ap_id(&self.object.object, data)?; let patch = Patch::from_str(&self.object.content)?; diff --git a/src/backend/federation/objects/articles_collection.rs b/src/backend/federation/objects/articles_collection.rs index 94bc273..e1fa63a 100644 --- a/src/backend/federation/objects/articles_collection.rs +++ b/src/backend/federation/objects/articles_collection.rs @@ -79,15 +79,19 @@ impl Collection for DbArticleCollection { _owner: &Self::Owner, data: &Data, ) -> Result { - join_all(apub.items.into_iter().map(|article| async { - let id = article.id.clone(); - let res = DbArticle::from_json(article, data).await; - if let Err(e) = &res { - warn!("Failed to synchronize article {id}: {e}"); - } - res - })) - .await; + let articles = + apub.items + .into_iter() + .filter(|i| !i.id.is_local(data)) + .map(|article| async { + let id = article.id.clone(); + let res = DbArticle::from_json(article, data).await; + if let Err(e) = &res { + warn!("Failed to synchronize article {id}: {e}"); + } + res + }); + join_all(articles).await; Ok(DbArticleCollection(())) } diff --git a/src/backend/federation/objects/instance_collection.rs b/src/backend/federation/objects/instance_collection.rs index 9670098..d91a1f7 100644 --- a/src/backend/federation/objects/instance_collection.rs +++ b/src/backend/federation/objects/instance_collection.rs @@ -79,15 +79,19 @@ impl Collection for DbInstanceCollection { _owner: &Self::Owner, data: &Data, ) -> Result { - join_all(apub.items.into_iter().map(|instance| async { - let id = instance.id.clone(); - let res = DbInstance::from_json(instance, data).await; - if let Err(e) = &res { - warn!("Failed to synchronize article {id}: {e}"); - } - res - })) - .await; + let instances = + apub.items + .into_iter() + .filter(|i| !i.id.is_local(data)) + .map(|instance| async { + let id = instance.id.clone(); + let res = DbInstance::from_json(instance, data).await; + if let Err(e) = &res { + warn!("Failed to synchronize article {id}: {e}"); + } + res + }); + join_all(instances).await; Ok(DbInstanceCollection(())) }