From e8379cb3f7e5fa69952832c91847419512468b4c Mon Sep 17 00:00:00 2001 From: Felix Ableitner Date: Wed, 21 Oct 2020 15:48:43 +0200 Subject: [PATCH] Also return json for long accept header with profile link (ref #1216) --- src/routes/federation.rs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/routes/federation.rs b/src/routes/federation.rs index 900631e5..52ba3e72 100644 --- a/src/routes/federation.rs +++ b/src/routes/federation.rs @@ -13,15 +13,21 @@ use lemmy_apub::{ use lemmy_utils::settings::Settings; use sha2::{Digest, Sha256}; +static APUB_JSON_CONTENT_TYPE_LONG: &str = + "application/ld+json; profile=\"https://www.w3.org/ns/activitystreams\""; + pub fn config(cfg: &mut web::ServiceConfig) { if Settings::get().federation.enabled { println!("federation enabled, host is {}", Settings::get().hostname); let digest_verifier = VerifyDigest::new(Sha256::new()); + let header_guard = guard::Any(guard::Header("Accept", APUB_JSON_CONTENT_TYPE)) + .or(guard::Header("Accept", APUB_JSON_CONTENT_TYPE_LONG)); + cfg .service( web::scope("/") - .guard(guard::Header("Accept", APUB_JSON_CONTENT_TYPE)) + .guard(header_guard) .route( "/c/{community_name}", web::get().to(get_apub_community_http), -- 2.44.1