fix: also full AP header

This commit is contained in:
əlemi 2024-03-26 21:02:07 +01:00
parent 2f5344af37
commit 46b9a339f7
Signed by: alemi
GPG key ID: A4895B84D311642C

View file

@ -101,7 +101,7 @@ async fn deliver(key: &PKey<Private>, to: &str, from: &str, payload: serde_json:
let payload = serde_json::to_string(&payload).unwrap(); let payload = serde_json::to_string(&payload).unwrap();
let digest = format!("sha-256={}", sha256::digest(&payload)); let digest = format!("sha-256={}", sha256::digest(&payload));
let host = Context::server(to); let host = Context::server(to);
let date = chrono::Utc::now().format("%d %b $Y %H:%M:%S %Z").to_string(); // TODO literally what the fuck let date = chrono::Utc::now().format("%d %b %Y %H:%M:%S %Z").to_string(); // TODO literally what the fuck
let headers : BTreeMap<String, String> = [ let headers : BTreeMap<String, String> = [
("Host".to_string(), host.clone()), ("Host".to_string(), host.clone()),
@ -124,13 +124,15 @@ async fn deliver(key: &PKey<Private>, to: &str, from: &str, payload: serde_json:
.unwrap() .unwrap()
.signature_header(); .signature_header();
tracing::info!("signature header: {signature_header}");
let res = reqwest::Client::new() let res = reqwest::Client::new()
.post(to) .post(to)
.header("Host", host) .header("Host", host)
.header("Date", date) .header("Date", date)
.header("Digest", digest) .header("Digest", digest)
.header("Signature", signature_header) .header("Signature", signature_header)
.header(CONTENT_TYPE, "application/ld+json") .header(CONTENT_TYPE, "application/ld+json; profile=\"https://www.w3.org/ns/activitystreams\"")
.header(USER_AGENT, format!("upub+{VERSION} ({domain})")) // TODO put instance admin email .header(USER_AGENT, format!("upub+{VERSION} ({domain})")) // TODO put instance admin email
.body(payload) .body(payload)
.send() .send()