This commit is contained in:
Felix Ableitner 2024-09-11 15:08:47 +02:00
parent 62b7543299
commit d0f37c699f
17 changed files with 26 additions and 27 deletions

View file

@ -11,6 +11,7 @@ use crate::{
use futures_core::Future;
use crate::url::Url;
use reqwest_middleware::ClientWithMiddleware;
use serde::Serialize;
use std::{
@ -26,7 +27,6 @@ use tokio::{
task::{JoinHandle, JoinSet},
};
use tracing::{info, warn};
use crate::url::Url;
/// Send a new activity to the given inboxes with automatic retry on failure. Alternatively you
/// can implement your own queue and then send activities using [[crate::activity_sending::SendActivityTask]].

View file

@ -8,6 +8,7 @@ use crate::{
http_signatures::sign_request,
reqwest_shim::ResponseExt,
traits::{ActivityHandler, Actor},
url::Url,
FEDERATION_CONTENT_TYPE,
};
use bytes::Bytes;
@ -27,7 +28,6 @@ use std::{
time::{Duration, SystemTime},
};
use tracing::debug;
use crate::url::Url;
#[derive(Clone, Debug)]
/// All info needed to sign and send one activity to one inbox. You should generally use

View file

@ -54,12 +54,12 @@ mod test {
fetch::object_id::ObjectId,
http_signatures::sign_request,
traits::tests::{DbConnection, DbUser, Follow, DB_USER_KEYPAIR},
url::Url,
};
use actix_web::test::TestRequest;
use reqwest::Client;
use reqwest_middleware::ClientWithMiddleware;
use serde_json::json;
use crate::url::Url;
#[tokio::test]
async fn test_receive_activity() {

View file

@ -19,6 +19,7 @@ use crate::{
error::Error,
protocol::verification::verify_domains_match,
traits::{ActivityHandler, Actor},
url::Url,
};
use async_trait::async_trait;
use derive_builder::Builder;
@ -35,7 +36,6 @@ use std::{
},
time::Duration,
};
use crate::url::Url;
/// Configuration for this library, with various federation related settings
#[derive(Builder, Clone)]

View file

@ -1,6 +1,6 @@
//! Error messages returned by this library
use crate::fetch::webfinger::WebFingerError;
use crate::{fetch::webfinger::WebFingerError, url::Url};
use http_signature_normalization_reqwest::SignError;
use rsa::{
errors::Error as RsaError,
@ -8,7 +8,6 @@ use rsa::{
};
use std::string::FromUtf8Error;
use tokio::task::JoinError;
use crate::url::Url;
/// Error messages returned by this library
#[derive(thiserror::Error, Debug)]

View file

@ -1,10 +1,10 @@
use crate::{config::Data, error::Error, fetch::fetch_object_http, traits::Collection};
use crate::{config::Data, error::Error, fetch::fetch_object_http, traits::Collection, url::Url};
use serde::{Deserialize, Serialize};
use std::{
fmt::{Debug, Display, Formatter},
marker::PhantomData, str::FromStr,
marker::PhantomData,
str::FromStr,
};
use crate::url::Url;
/// Typed wrapper for Activitypub Collection ID which helps with dereferencing.
#[derive(Serialize, Deserialize)]

View file

@ -8,6 +8,7 @@ use crate::{
extract_id,
http_signatures::sign_request,
reqwest_shim::ResponseExt,
url::Url,
FEDERATION_CONTENT_TYPE,
};
use bytes::Bytes;
@ -15,7 +16,6 @@ use http::{HeaderValue, StatusCode};
use serde::de::DeserializeOwned;
use std::sync::atomic::Ordering;
use tracing::info;
use crate::url::Url;
/// Typed wrapper for collection IDs
pub mod collection_id;

View file

@ -1,4 +1,4 @@
use crate::{config::Data, error::Error, fetch::fetch_object_http, traits::Object};
use crate::{config::Data, error::Error, fetch::fetch_object_http, traits::Object, url::Url};
use chrono::{DateTime, Duration as ChronoDuration, Utc};
use serde::{Deserialize, Serialize};
use std::{
@ -6,7 +6,6 @@ use std::{
marker::PhantomData,
str::FromStr,
};
use crate::url::Url;
impl<T> FromStr for ObjectId<T>
where

View file

@ -3,6 +3,7 @@ use crate::{
error::Error,
fetch::{fetch_object_http_with_accept, object_id::ObjectId},
traits::{Actor, Object},
url::Url,
FEDERATION_CONTENT_TYPE,
};
use http::HeaderValue;
@ -12,7 +13,6 @@ use regex::Regex;
use serde::{Deserialize, Serialize};
use std::{collections::HashMap, fmt::Display, str::FromStr};
use tracing::debug;
use crate::url::Url;
/// Errors relative to webfinger handling
#[derive(thiserror::Error, Debug)]

View file

@ -11,6 +11,7 @@ use crate::{
fetch::object_id::ObjectId,
protocol::public_key::main_key_id,
traits::{Actor, Object},
url::Url,
};
use base64::{engine::general_purpose::STANDARD as Base64, Engine};
use bytes::Bytes;
@ -32,7 +33,6 @@ use serde::Deserialize;
use sha2::{Digest, Sha256};
use std::{collections::BTreeMap, fmt::Debug, str::FromStr, time::Duration};
use tracing::debug;
use crate::url::Url;
/// A private/public key pair used for HTTP signatures
#[derive(Debug, Clone)]
@ -287,7 +287,8 @@ pub mod test {
use rsa::{pkcs1::DecodeRsaPrivateKey, pkcs8::DecodePrivateKey};
use std::str::FromStr;
static ACTOR_ID: Lazy<Url> = Lazy::new(|| Url::from_str("https://example.com/u/alice").unwrap());
static ACTOR_ID: Lazy<Url> =
Lazy::new(|| Url::from_str("https://example.com/u/alice").unwrap());
static INBOX_URL: Lazy<Url> =
Lazy::new(|| Url::from_str("https://example.com/u/alice/inbox").unwrap());

View file

@ -33,8 +33,8 @@ use crate::{
};
pub use activitystreams_kinds as kinds;
use serde::{de::DeserializeOwned, Deserialize};
use crate::url::Url;
use serde::{de::DeserializeOwned, Deserialize};
/// Mime type for Activitypub data, used for `Accept` and `Content-Type` HTTP headers
pub const FEDERATION_CONTENT_TYPE: &str = "application/activity+json";

View file

@ -19,10 +19,9 @@
//! Ok::<(), serde_json::error::Error>(())
//! ```
use crate::{config::Data, traits::ActivityHandler};
use crate::{config::Data, traits::ActivityHandler, url::Url};
use serde::{Deserialize, Serialize};
use serde_json::Value;
use crate::url::Url;
/// Default context used in Activitypub
const DEFAULT_CONTEXT: &str = "https://www.w3.org/ns/activitystreams";

View file

@ -120,8 +120,7 @@ where
mod tests {
#[test]
fn deserialize_one_multiple_values() {
use crate::protocol::helpers::deserialize_one;
use crate::url::Url;
use crate::{protocol::helpers::deserialize_one, url::Url};
#[derive(serde::Deserialize)]
struct Note {
#[serde(deserialize_with = "deserialize_one")]

View file

@ -1,7 +1,7 @@
//! Struct which is used to federate actor key for HTTP signatures
use serde::{Deserialize, Serialize};
use crate::url::Url;
use serde::{Deserialize, Serialize};
/// Public key of actors which is used for HTTP signatures.
///

View file

@ -1,7 +1,6 @@
//! Verify that received data is valid
use crate::error::Error;
use crate::url::Url;
use crate::{error::Error, url::Url};
/// Check that both urls have the same domain. If not, return UrlVerificationError.
///

View file

@ -1,11 +1,10 @@
//! Traits which need to be implemented for federated data types
use crate::{config::Data, protocol::public_key::PublicKey};
use crate::{config::Data, protocol::public_key::PublicKey, url::Url};
use async_trait::async_trait;
use chrono::{DateTime, Utc};
use serde::Deserialize;
use std::{fmt::Debug, ops::Deref};
use crate::url::Url;
/// Helper for converting between database structs and federated protocol structs.
///

View file

@ -1,6 +1,10 @@
//! Wrapper for `url::Url` type.
use std::{fmt::{Display, Formatter}, ops::Deref, str::FromStr};
use std::{
fmt::{Display, Formatter},
ops::Deref,
str::FromStr,
};
use serde::{Deserialize, Serialize};
@ -43,4 +47,4 @@ impl FromStr for Url {
fn from_str(s: &str) -> Result<Self, Self::Err> {
Ok(url::Url::from_str(s).map(Url).unwrap())
}
}
}