From 7f12663a949a5259494deecb233c620198271a0a Mon Sep 17 00:00:00 2001 From: Felix Ableitner Date: Fri, 20 Dec 2024 23:42:45 +0100 Subject: [PATCH] Support standard activitypub accept header (fixes #100) --- src/backend/mod.rs | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/src/backend/mod.rs b/src/backend/mod.rs index 34c51f3..719eb2b 100644 --- a/src/backend/mod.rs +++ b/src/backend/mod.rs @@ -225,9 +225,16 @@ async fn federation_routes_middleware(request: Request, next: Next) -> Res let (mut parts, body) = request.into_parts(); // rewrite uri based on accept header let mut uri = parts.uri.to_string(); - let accept_value = HeaderValue::from_static("application/activity+json"); - if Some(&accept_value) == parts.headers.get("Accept") - || Some(&accept_value) == parts.headers.get("Content-Type") + const VALUE1: HeaderValue = HeaderValue::from_static("application/activity+json"); + const VALUE2: HeaderValue = HeaderValue::from_static( + r#"application/ld+json; profile="https://www.w3.org/ns/activitystreams""#, + ); + let accept = parts.headers.get("Accept"); + let content_type = parts.headers.get("Content-Type"); + if Some(&VALUE1) == accept + || Some(&VALUE2) == accept + || Some(&VALUE1) == content_type + || Some(&VALUE2) == content_type { uri = format!("{FEDERATION_ROUTES_PREFIX}{uri}"); }