diff --git a/Cargo.toml b/Cargo.toml index 5ac2d79..58d0e97 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -32,67 +32,67 @@ redundant_closure_for_method_calls = "deny" unwrap_used = "deny" [dependencies] -chrono = { version = "0.4.38", features = ["clock"], default-features = false } -serde = { version = "1.0.204", features = ["derive"] } -async-trait = "0.1.81" -url = { version = "2.5.2", features = ["serde"] } -serde_json = { version = "1.0.120", features = ["preserve_order"] } -reqwest = { version = "0.12.5", default-features = false, features = [ +chrono = { version = "0.4.39", features = ["clock"], default-features = false } +serde = { version = "1.0.217", features = ["derive"] } +async-trait = "0.1.85" +url = { version = "2.5.4", features = ["serde"] } +serde_json = { version = "1.0.137", features = ["preserve_order"] } +reqwest = { version = "0.12.12", default-features = false, features = [ "json", "stream", "rustls-tls", ] } -reqwest-middleware = "0.3.2" -tracing = "0.1.40" +reqwest-middleware = "0.4.0" +tracing = "0.1.41" base64 = "0.22.1" rand = "0.8.5" -rsa = "0.9.6" -once_cell = "1.19.0" -http = "1.1.0" +rsa = "0.9.7" +once_cell = "1.20.2" +http = "1.2.0" sha2 = { version = "0.10.8", features = ["oid"] } -thiserror = "1.0.62" -derive_builder = "0.20.0" -itertools = "0.13.0" +thiserror = "2.0.11" +derive_builder = "0.20.2" +itertools = "0.14.0" dyn-clone = "1.0.17" enum_delegate = "0.2.0" httpdate = "1.0.3" -http-signature-normalization-reqwest = { version = "0.12.0", default-features = false, features = [ +http-signature-normalization-reqwest = { version = "0.13.0", default-features = false, features = [ "sha-2", "middleware", "default-spawner", ] } http-signature-normalization = "0.7.0" -bytes = "1.6.1" -futures-core = { version = "0.3.30", default-features = false } -pin-project-lite = "0.2.14" +bytes = "1.9.0" +futures-core = { version = "0.3.31", default-features = false } +pin-project-lite = "0.2.16" activitystreams-kinds = "0.3.0" -regex = { version = "1.10.5", default-features = false, features = [ +regex = { version = "1.11.1", default-features = false, features = [ "std", "unicode", ] } -tokio = { version = "1.38.0", features = [ +tokio = { version = "1.43.0", features = [ "sync", "rt", "rt-multi-thread", "time", ] } -diesel = { version = "2.2.1", features = [ +diesel = { version = "2.2.6", features = [ "postgres", ], default-features = false, optional = true } -futures = "0.3.30" -moka = { version = "0.12.8", features = ["future"] } +futures = "0.3.31" +moka = { version = "0.12.10", features = ["future"] } # Actix-web -actix-web = { version = "4.8.0", default-features = false, optional = true } +actix-web = { version = "4.9.0", default-features = false, optional = true } http02 = { package = "http", version = "0.2.12", optional = true } # Axum -axum = { version = "0.7.5", features = ["json"], default-features = false, optional = true } -tower = { version = "0.4.13", optional = true } +axum = { version = "0.8.2", features = ["json"], default-features = false, optional = true } +tower = { version = "0.5.2", optional = true } [dev-dependencies] -anyhow = "1.0.86" -axum = { version = "0.7.5", features = ["macros"] } +anyhow = "1.0.95" +axum = { version = "0.8.2", features = ["macros"] } axum-extra = { version = "0.9.3", features = ["typed-header"] } env_logger = "0.11.3" tokio = { version = "1.38.0", features = ["full"] } diff --git a/src/activity_queue.rs b/src/activity_queue.rs index c666e7a..5025e49 100644 --- a/src/activity_queue.rs +++ b/src/activity_queue.rs @@ -361,10 +361,10 @@ impl ActivityQueue { pub(crate) async fn shutdown(self, wait_for_retries: bool) -> Result, Error> { drop(self.sender); - self.sender_task.await?; + self.sender_task.await.map_err(|_| Error::NotFound)?; if wait_for_retries { - self.retry_sender_task.await?; + self.retry_sender_task.await.map_err(|_| Error::NotFound)?; } Ok(self.stats) diff --git a/src/axum/inbox.rs b/src/axum/inbox.rs index 1767c10..eb2a4d9 100644 --- a/src/axum/inbox.rs +++ b/src/axum/inbox.rs @@ -9,8 +9,8 @@ use crate::{ parse_received_activity, traits::{ActivityHandler, Actor, Object}, }; +use async_trait::async_trait; use axum::{ - async_trait, body::Body, extract::FromRequest, http::{Request, StatusCode}, diff --git a/src/axum/middleware.rs b/src/axum/middleware.rs index 290dc94..be76ab3 100644 --- a/src/axum/middleware.rs +++ b/src/axum/middleware.rs @@ -1,5 +1,6 @@ use crate::config::{Data, FederationConfig, FederationMiddleware}; -use axum::{async_trait, body::Body, extract::FromRequestParts, http::Request, response::Response}; +use async_trait::async_trait; +use axum::{body::Body, extract::FromRequestParts, http::Request, response::Response}; use http::{request::Parts, StatusCode}; use std::task::{Context, Poll}; use tower::{Layer, Service}; diff --git a/src/error.rs b/src/error.rs index 1866e48..fa4a71b 100644 --- a/src/error.rs +++ b/src/error.rs @@ -101,6 +101,42 @@ impl From for Error { } } +impl From for Error { + fn from(value: url::ParseError) -> Self { + Error::UrlParse(value) + } +} + +impl From for Error { + fn from(value: WebFingerError) -> Self { + Error::WebfingerResolveFailed(value) + } +} + +impl From for Error { + fn from(value: FromUtf8Error) -> Self { + Error::Utf8(value) + } +} + +impl From for Error { + fn from(value: SignError) -> Self { + Error::SignError(value) + } +} + +impl From for Error { + fn from(value: reqwest::Error) -> Self { + Error::Reqwest(value) + } +} + +impl From for Error { + fn from(value: reqwest_middleware::Error) -> Self { + Error::ReqwestMiddleware(value) + } +} + impl PartialEq for Error { fn eq(&self, other: &Self) -> bool { std::mem::discriminant(self) == std::mem::discriminant(other) diff --git a/src/fetch/webfinger.rs b/src/fetch/webfinger.rs index 8460245..f66a181 100644 --- a/src/fetch/webfinger.rs +++ b/src/fetch/webfinger.rs @@ -126,12 +126,14 @@ where // TODO: This should use a URL parser let captures = WEBFINGER_REGEX .captures(query) - .ok_or(WebFingerError::WrongFormat)?; + .ok_or(WebFingerError::WrongFormat.into_crate_error())?; - let account_name = captures.get(1).ok_or(WebFingerError::WrongFormat)?; + let account_name = captures + .get(1) + .ok_or(WebFingerError::WrongFormat.into_crate_error())?; if captures.get(2).map(|m| m.as_str()) != Some(data.domain()) { - return Err(WebFingerError::WrongDomain.into()); + return Err(WebFingerError::WrongDomain.into_crate_error()); } Ok(account_name.as_str()) }