- payload: Payload,
- context: web::Data<LemmyContext>,
-) -> Result<HttpResponse, LemmyError> {
- let unparsed = payload_to_string(payload).await?;
- trace!("Received shared inbox activity {}", unparsed);
- let activity = serde_json::from_str::<SharedInboxActivities>(&unparsed)?;
- match activity {
- SharedInboxActivities::GroupInboxActivities(g) => {
- receive_group_inbox(g, request, &context).await
- }
- SharedInboxActivities::PersonInboxActivities(p) => {
- receive_person_inbox(p, request, &context).await
- }
- }
-}
-
-async fn payload_to_string(mut payload: Payload) -> Result<String, LemmyError> {
- let mut bytes = BytesMut::new();
- while let Some(item) = payload.next().await {
- bytes.extend_from_slice(&item?);
- }
- let mut unparsed = String::new();
- Bytes::from(bytes).as_ref().read_to_string(&mut unparsed)?;
- Ok(unparsed)
+ body: Bytes,
+ data: Data<LemmyContext>,
+) -> LemmyResult<HttpResponse> {
+ receive_activity::<SharedInboxActivities, UserOrCommunity, LemmyContext>(request, body, &data)
+ .await