mirror of
https://github.com/LemmyNet/activitypub-federation-rust
synced 2024-11-23 11:53:04 +00:00
Revert change to take payload in inbox, it wasnt necessary.
This commit is contained in:
parent
8ee52826a1
commit
05ad7b2f3a
4 changed files with 11 additions and 19 deletions
2
Cargo.lock
generated
2
Cargo.lock
generated
|
@ -4,7 +4,7 @@ version = 3
|
|||
|
||||
[[package]]
|
||||
name = "activitypub_federation"
|
||||
version = "0.3.0"
|
||||
version = "0.3.1"
|
||||
dependencies = [
|
||||
"activitystreams-kinds",
|
||||
"actix-rt",
|
||||
|
|
|
@ -16,7 +16,7 @@ use activitypub_federation::{
|
|||
UrlVerifier,
|
||||
APUB_JSON_CONTENT_TYPE,
|
||||
};
|
||||
use actix_web::{web, web::Payload, App, HttpRequest, HttpResponse, HttpServer};
|
||||
use actix_web::{web, App, HttpRequest, HttpResponse, HttpServer};
|
||||
use async_trait::async_trait;
|
||||
use http_signature_normalization_actix::prelude::VerifyDigest;
|
||||
use reqwest::Client;
|
||||
|
@ -124,13 +124,14 @@ async fn http_get_user(
|
|||
/// Handles messages received in user inbox
|
||||
async fn http_post_user_inbox(
|
||||
request: HttpRequest,
|
||||
payload: Payload,
|
||||
payload: String,
|
||||
data: web::Data<InstanceHandle>,
|
||||
) -> Result<HttpResponse, Error> {
|
||||
let data: InstanceHandle = data.into_inner().deref().clone();
|
||||
let activity = serde_json::from_str(&payload)?;
|
||||
receive_activity::<WithContext<PersonAcceptedActivities>, MyUser, InstanceHandle>(
|
||||
request,
|
||||
payload.into_inner(),
|
||||
activity,
|
||||
&data.clone().local_instance,
|
||||
&Data::new(data),
|
||||
)
|
||||
|
|
|
@ -6,16 +6,15 @@ use crate::{
|
|||
Error,
|
||||
LocalInstance,
|
||||
};
|
||||
use actix_web::{dev::Payload, web::Bytes, FromRequest, HttpRequest, HttpResponse};
|
||||
use anyhow::anyhow;
|
||||
use actix_web::{dev::Payload, FromRequest, HttpRequest, HttpResponse};
|
||||
use http_signature_normalization_actix::prelude::DigestVerified;
|
||||
use serde::de::DeserializeOwned;
|
||||
use tracing::{log::debug, warn};
|
||||
use tracing::log::debug;
|
||||
|
||||
/// Receive an activity and perform some basic checks, including HTTP signature verification.
|
||||
pub async fn receive_activity<Activity, ActorT, Datatype>(
|
||||
request: HttpRequest,
|
||||
mut payload: Payload,
|
||||
activity: Activity,
|
||||
local_instance: &LocalInstance,
|
||||
data: &Data<Datatype>,
|
||||
) -> Result<HttpResponse, <Activity as ActivityHandler>::Error>
|
||||
|
@ -31,15 +30,7 @@ where
|
|||
<ActorT as ApubObject>::Error: From<Error> + From<anyhow::Error>,
|
||||
{
|
||||
// ensure that payload hash was checked against digest header by middleware
|
||||
DigestVerified::from_request(&request, &mut payload).await?;
|
||||
|
||||
let bytes = Bytes::from_request(&request, &mut payload)
|
||||
.await
|
||||
.map_err(|e| {
|
||||
warn!("{}", e);
|
||||
anyhow!("Failed to parse request body")
|
||||
})?;
|
||||
let activity: Activity = serde_json::from_slice(&bytes)?;
|
||||
DigestVerified::from_request(&request, &mut Payload::None).await?;
|
||||
|
||||
verify_domains_match(activity.id(), activity.actor())?;
|
||||
verify_url_valid(activity.id(), &local_instance.settings).await?;
|
||||
|
|
|
@ -55,7 +55,7 @@ where
|
|||
data: &Data<Self::DataType>,
|
||||
request_counter: &mut i32,
|
||||
) -> Result<(), Self::Error> {
|
||||
self.verify(data, request_counter).await
|
||||
self.deref().verify(data, request_counter).await
|
||||
}
|
||||
|
||||
async fn receive(
|
||||
|
@ -63,7 +63,7 @@ where
|
|||
data: &Data<Self::DataType>,
|
||||
request_counter: &mut i32,
|
||||
) -> Result<(), Self::Error> {
|
||||
self.receive(data, request_counter).await
|
||||
(*self).receive(data, request_counter).await
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue