From 1c03a86c17219715c2de4e4ee5111fe5ae6cfb64 Mon Sep 17 00:00:00 2001 From: cetra3 Date: Tue, 21 Nov 2023 19:56:12 +1030 Subject: [PATCH] Upgrade activitypub to `0.5.0-beta.5` (#4179) * Remove anyhow test * Update lock * Fix lints hopefully! --- Cargo.lock | 6 ++---- Cargo.toml | 2 +- crates/apub/src/lib.rs | 16 +++++++++------- crates/federate/Cargo.toml | 1 - crates/federate/src/worker.rs | 6 ++---- 5 files changed, 14 insertions(+), 17 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 66b91dbac..fb032aec2 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -10,13 +10,12 @@ checksum = "fe438c63458706e03479442743baae6c88256498e6431708f6dfc520a26515d3" [[package]] name = "activitypub_federation" -version = "0.5.0-beta.4" +version = "0.5.0-beta.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9a122cf2c2adf45b164134946bc069659cd93083fab294839a3f1d794b707c17" +checksum = "eb3d9484e58e121ce93b84407e077f5888526a8edccb8a8447d14e3ff611aaa3" dependencies = [ "activitystreams-kinds", "actix-web", - "anyhow", "async-trait", "base64 0.21.5", "bytes", @@ -2745,7 +2744,6 @@ dependencies = [ "lemmy_apub", "lemmy_db_schema", "lemmy_db_views_actor", - "lemmy_utils", "moka", "once_cell", "reqwest", diff --git a/Cargo.toml b/Cargo.toml index c7c878292..f51c07bad 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -69,7 +69,7 @@ lemmy_routes = { version = "=0.19.0-rc.5", path = "./crates/routes" } lemmy_db_views = { version = "=0.19.0-rc.5", path = "./crates/db_views" } lemmy_db_views_actor = { version = "=0.19.0-rc.5", path = "./crates/db_views_actor" } lemmy_db_views_moderator = { version = "=0.19.0-rc.5", path = "./crates/db_views_moderator" } -activitypub_federation = { version = "0.5.0-beta.4", default-features = false, features = [ +activitypub_federation = { version = "0.5.0-beta.5", default-features = false, features = [ "actix-web", ] } diesel = "2.1.3" diff --git a/crates/apub/src/lib.rs b/crates/apub/src/lib.rs index 1ae214c19..0d76a78b0 100644 --- a/crates/apub/src/lib.rs +++ b/crates/apub/src/lib.rs @@ -1,6 +1,8 @@ use crate::fetcher::post_or_comment::PostOrComment; -use activitypub_federation::config::{Data, UrlVerifier}; -use anyhow::anyhow; +use activitypub_federation::{ + config::{Data, UrlVerifier}, + error::Error as ActivityPubError, +}; use async_trait::async_trait; use lemmy_api_common::context::LemmyContext; use lemmy_db_schema::{ @@ -39,7 +41,7 @@ pub struct VerifyUrlData(pub ActualDbPool); #[async_trait] impl UrlVerifier for VerifyUrlData { - async fn verify(&self, url: &Url) -> Result<(), anyhow::Error> { + async fn verify(&self, url: &Url) -> Result<(), ActivityPubError> { let local_site_data = local_site_data_cached(&mut (&self.0).into()) .await .expect("read local site data"); @@ -47,16 +49,16 @@ impl UrlVerifier for VerifyUrlData { LemmyError { error_type: LemmyErrorType::FederationDisabled, .. - } => anyhow!("Federation disabled"), + } => ActivityPubError::Other("Federation disabled".into()), LemmyError { error_type: LemmyErrorType::DomainBlocked(domain), .. - } => anyhow!("Domain {domain:?} is blocked"), + } => ActivityPubError::Other(format!("Domain {domain:?} is blocked")), LemmyError { error_type: LemmyErrorType::DomainNotInAllowList(domain), .. - } => anyhow!("Domain {domain:?} is not in allowlist"), - _ => anyhow!("Failed validating apub id"), + } => ActivityPubError::Other(format!("Domain {domain:?} is not in allowlist")), + _ => ActivityPubError::Other("Failed validating apub id".into()), })?; Ok(()) } diff --git a/crates/federate/Cargo.toml b/crates/federate/Cargo.toml index c098f9f5b..e573ffe6c 100644 --- a/crates/federate/Cargo.toml +++ b/crates/federate/Cargo.toml @@ -15,7 +15,6 @@ lemmy_api_common.workspace = true lemmy_apub.workspace = true lemmy_db_schema = { workspace = true, features = ["full"] } lemmy_db_views_actor.workspace = true -lemmy_utils.workspace = true activitypub_federation.workspace = true anyhow.workspace = true diff --git a/crates/federate/src/worker.rs b/crates/federate/src/worker.rs index 8e7726fee..ad2b5b7d2 100644 --- a/crates/federate/src/worker.rs +++ b/crates/federate/src/worker.rs @@ -21,7 +21,6 @@ use lemmy_db_schema::{ utils::DbPool, }; use lemmy_db_views_actor::structs::CommunityFollowerView; -use lemmy_utils::error::LemmyErrorExt2; use once_cell::sync::Lazy; use reqwest::Url; use std::{ @@ -218,9 +217,8 @@ impl InstanceWorker { .context("failed getting actor instance (was it marked deleted / removed?)")?; let inbox_urls = inbox_urls.into_iter().collect(); - let requests = SendActivityTask::prepare(object, actor.as_ref(), inbox_urls, &self.context) - .await - .into_anyhow()?; + let requests = + SendActivityTask::prepare(object, actor.as_ref(), inbox_urls, &self.context).await?; for task in requests { // usually only one due to shared inbox tracing::info!("sending out {}", task);