Take dev::Payload for inbox which is more flexible

This commit is contained in:
Felix Ableitner 2022-11-14 16:11:36 +01:00
parent aeba7f38bb
commit 11fcb62416
3 changed files with 4 additions and 10 deletions

2
Cargo.lock generated
View file

@ -4,7 +4,7 @@ version = 3
[[package]]
name = "activitypub_federation"
version = "0.2.3"
version = "0.3.0"
dependencies = [
"activitystreams-kinds",
"actix-rt",

View file

@ -130,7 +130,7 @@ async fn http_post_user_inbox(
let data: InstanceHandle = data.into_inner().deref().clone();
receive_activity::<WithContext<PersonAcceptedActivities>, MyUser, InstanceHandle>(
request,
payload,
payload.into_inner(),
&data.clone().local_instance,
&Data::new(data),
)

View file

@ -6,12 +6,7 @@ use crate::{
Error,
LocalInstance,
};
use actix_web::{
web::{Bytes, Payload},
FromRequest,
HttpRequest,
HttpResponse,
};
use actix_web::{dev::Payload, web::Bytes, FromRequest, HttpRequest, HttpResponse};
use anyhow::anyhow;
use http_signature_normalization_actix::prelude::DigestVerified;
use serde::de::DeserializeOwned;
@ -20,7 +15,7 @@ use tracing::{log::debug, warn};
/// Receive an activity and perform some basic checks, including HTTP signature verification.
pub async fn receive_activity<Activity, ActorT, Datatype>(
request: HttpRequest,
payload: Payload,
mut payload: Payload,
local_instance: &LocalInstance,
data: &Data<Datatype>,
) -> Result<HttpResponse, <Activity as ActivityHandler>::Error>
@ -35,7 +30,6 @@ where
+ From<http_signature_normalization_actix::digest::middleware::VerifyError>,
<ActorT as ApubObject>::Error: From<Error> + From<anyhow::Error>,
{
let mut payload = payload.into_inner();
// ensure that payload hash was checked against digest header by middleware
DigestVerified::from_request(&request, &mut payload).await?;