diff --git a/src/actix_web/inbox.rs b/src/actix_web/inbox.rs index 3abdd65..a2b55d4 100644 --- a/src/actix_web/inbox.rs +++ b/src/actix_web/inbox.rs @@ -122,17 +122,15 @@ mod test { let incoming_request = construct_request(&body, &actor).await; // intentionally cause a parse error by using wrong type for deser - let err = receive_activity::( + let res = receive_activity::( incoming_request.to_http_request(), body, &config.to_request_data(), ) - .await - .err() - .unwrap(); + .await; - match err { - Error::ParseReceivedActivity(url, _) => { + match res { + Err(Error::ParseReceivedActivity(url, _)) => { assert_eq!(id, url.as_str()); } _ => unreachable!(), diff --git a/src/lib.rs b/src/lib.rs index 8c35b4a..42da8df 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -37,6 +37,8 @@ use url::Url; /// Mime type for Activitypub data, used for `Accept` and `Content-Type` HTTP headers pub static FEDERATION_CONTENT_TYPE: &str = "application/activity+json"; +/// Deserialize incoming inbox activity to the given type, perform basic +/// validation and extract the actor. async fn parse_received_activity( body: &[u8], data: &Data, @@ -50,7 +52,7 @@ where Datatype: Clone, { let activity: Activity = serde_json::from_slice(body).map_err(|e| { - // Attempt to parse only activity id for error message + // Attempt to include activity id in error message #[derive(Deserialize)] struct Id { id: Url,