extensions::signatures::sign_and_send,
insert_activity,
ActorType,
+ APUB_JSON_CONTENT_TYPE,
};
use activitystreams::{
base::{BaseExt, Extends, ExtendsExt},
fn run(self, state: Self::State) -> Self::Future {
Box::pin(async move {
let mut headers = BTreeMap::<String, String>::new();
- headers.insert("Content-Type".into(), "application/json".into());
+ headers.insert("Content-Type".into(), APUB_JSON_CONTENT_TYPE.to_string());
let result = sign_and_send(
&state.client,
headers,
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))
+ let header_guard_accept = guard::Any(guard::Header("Accept", APUB_JSON_CONTENT_TYPE))
.or(guard::Header("Accept", APUB_JSON_CONTENT_TYPE_LONG));
+ let header_guard_content_type =
+ guard::Any(guard::Header("Content-Type", APUB_JSON_CONTENT_TYPE))
+ .or(guard::Header("Content-Type", APUB_JSON_CONTENT_TYPE_LONG))
+ // TODO: compatibility with previous lemmy versions, remove this later
+ .or(guard::Header("Content-Type", "application/json"));
cfg
.service(
web::scope("/")
- .guard(header_guard)
+ .guard(header_guard_accept)
.route(
"/c/{community_name}",
web::get().to(get_apub_community_http),
)
// Inboxes dont work with the header guard for some reason.
.service(
- web::resource("/c/{community_name}/inbox")
- .wrap(digest_verifier.clone())
- .route(web::post().to(community_inbox)),
- )
- .service(
- web::resource("/u/{user_name}/inbox")
- .wrap(digest_verifier.clone())
- .route(web::post().to(user_inbox)),
- )
- .service(
- web::resource("/inbox")
+ web::scope("/")
.wrap(digest_verifier)
- .route(web::post().to(shared_inbox)),
+ .guard(header_guard_content_type)
+ .route("/c/{community_name}/inbox", web::post().to(community_inbox))
+ .route("/u/{user_name}/inbox", web::post().to(user_inbox))
+ .route("/inbox", web::post().to(shared_inbox)),
);
}
}