diff --git a/src/activity_sending.rs b/src/activity_sending.rs index 94158a2..0c5f2f2 100644 --- a/src/activity_sending.rs +++ b/src/activity_sending.rs @@ -11,6 +11,7 @@ use crate::{ FEDERATION_CONTENT_TYPE, }; use bytes::Bytes; +use chrono::{DateTime, Utc}; use futures::StreamExt; use httpdate::fmt_http_date; use itertools::Itertools; @@ -22,7 +23,6 @@ use std::{ fmt::{Debug, Display}, time::{Duration, SystemTime}, }; -use chrono::{DateTime, Utc}; use tracing::debug; use url::Url; @@ -133,10 +133,10 @@ where let activity_id = activity.id(); let activity_serialized: Bytes = match published { Some(published) => serde_json::to_vec(&WithPublished::new(activity, published)), - None => serde_json::to_vec(activity) + None => serde_json::to_vec(activity), } - .map_err(|e| Error::SerializeOutgoingActivity(e, format!("{:?}", activity)))? - .into(); + .map_err(|e| Error::SerializeOutgoingActivity(e, format!("{:?}", activity)))? + .into(); let private_key = get_pkey_cached(data, actor).await?; Ok(futures::stream::iter( @@ -228,10 +228,7 @@ struct WithPublished { impl WithPublished { pub fn new(inner: T, published: DateTime) -> WithPublished { - Self { - published, - inner, - } + Self { published, inner } } } diff --git a/src/actix_web/inbox.rs b/src/actix_web/inbox.rs index b9c6379..a6e79dd 100644 --- a/src/actix_web/inbox.rs +++ b/src/actix_web/inbox.rs @@ -39,6 +39,10 @@ where )?; debug!("Receiving activity {}", activity.id().to_string()); + + // TODO: need to throw received activities in a queue ordered by published timestamp, then + // process in order. tricky due to generics. probably need one queue per sending instance. + activity.verify(data).await?; activity.receive(data).await?; Ok(HttpResponse::Ok().finish()) diff --git a/src/traits.rs b/src/traits.rs index ee680f0..720f731 100644 --- a/src/traits.rs +++ b/src/traits.rs @@ -343,7 +343,7 @@ pub mod tests { error::Error, fetch::object_id::ObjectId, http_signatures::{generate_actor_keypair, Keypair}, - protocol::{verification::verify_domains_match}, + protocol::verification::verify_domains_match, }; use activitystreams_kinds::{activity::FollowType, actor::PersonType}; use once_cell::sync::Lazy;