mirror of
https://git.joinplu.me/Plume/Plume.git
synced 2024-11-20 10:31:17 +00:00
Merge pull request 'Fix #892 Build client for every inbox in broadcast()' (#895) from broadcast-timeout into main
Reviewed-on: https://git.joinplu.me/Plume/Plume/pulls/895
This commit is contained in:
commit
10be055381
1 changed files with 27 additions and 24 deletions
|
@ -132,14 +132,6 @@ where
|
||||||
|
|
||||||
let mut rt = tokio::runtime::current_thread::Runtime::new()
|
let mut rt = tokio::runtime::current_thread::Runtime::new()
|
||||||
.expect("Error while initializing tokio runtime for federation");
|
.expect("Error while initializing tokio runtime for federation");
|
||||||
let client = if let Some(proxy) = proxy {
|
|
||||||
ClientBuilder::new().proxy(proxy)
|
|
||||||
} else {
|
|
||||||
ClientBuilder::new()
|
|
||||||
}
|
|
||||||
.connect_timeout(std::time::Duration::from_secs(5))
|
|
||||||
.build()
|
|
||||||
.expect("Can't build client");
|
|
||||||
for inbox in boxes {
|
for inbox in boxes {
|
||||||
let body = signed.to_string();
|
let body = signed.to_string();
|
||||||
let mut headers = request::headers();
|
let mut headers = request::headers();
|
||||||
|
@ -161,7 +153,14 @@ where
|
||||||
headers.insert("Host", host_header_value.unwrap());
|
headers.insert("Host", host_header_value.unwrap());
|
||||||
headers.insert("Digest", request::Digest::digest(&body));
|
headers.insert("Digest", request::Digest::digest(&body));
|
||||||
rt.spawn(
|
rt.spawn(
|
||||||
client
|
if let Some(proxy) = proxy.clone() {
|
||||||
|
ClientBuilder::new().proxy(proxy)
|
||||||
|
} else {
|
||||||
|
ClientBuilder::new()
|
||||||
|
}
|
||||||
|
.connect_timeout(std::time::Duration::from_secs(5))
|
||||||
|
.build()
|
||||||
|
.expect("Can't build client")
|
||||||
.post(&inbox)
|
.post(&inbox)
|
||||||
.headers(headers.clone())
|
.headers(headers.clone())
|
||||||
.header(
|
.header(
|
||||||
|
@ -171,11 +170,15 @@ where
|
||||||
)
|
)
|
||||||
.body(body)
|
.body(body)
|
||||||
.send()
|
.send()
|
||||||
.and_then(|r| r.into_body().concat2())
|
.and_then(move |r| {
|
||||||
.map(move |response| {
|
if r.status().is_success() {
|
||||||
debug!("Successfully sent activity to inbox ({})", inbox);
|
debug!("Successfully sent activity to inbox ({})", &inbox);
|
||||||
debug!("Response: \"{:?}\"\n", response)
|
} else {
|
||||||
|
warn!("Error while sending to inbox ({:?})", &r)
|
||||||
|
}
|
||||||
|
r.into_body().concat2()
|
||||||
})
|
})
|
||||||
|
.map(move |response| debug!("Response: \"{:?}\"\n", response))
|
||||||
.map_err(|e| warn!("Error while sending to inbox ({:?})", e)),
|
.map_err(|e| warn!("Error while sending to inbox ({:?})", e)),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue