This commit is contained in:
Felix Ableitner 2023-12-12 11:17:00 +01:00
parent b479e9ac95
commit 7509ed6425
2 changed files with 7 additions and 7 deletions

View file

@ -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::<Follow, DbUser, DbConnection>(
let res = receive_activity::<Follow, DbUser, DbConnection>(
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!(),

View file

@ -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<Activity, ActorT, Datatype>(
body: &[u8],
data: &Data<Datatype>,
@ -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,