Upgrade activitypub to 0.5.0-beta.5 (#4179)

* Remove anyhow test

* Update lock

* Fix lints hopefully!
This commit is contained in:
cetra3 2023-11-21 19:56:12 +10:30 committed by GitHub
parent f786df151f
commit 1c03a86c17
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 14 additions and 17 deletions

6
Cargo.lock generated
View File

@ -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",

View File

@ -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"

View File

@ -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(())
}

View File

@ -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

View File

@ -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);