mirror of
https://github.com/Jeuners/ECC.git
synced 2026-09-09 15:02:30 +02:00
fix(ecc2): port webhook sender to ureq 3 Agent API (#2231)
#2209 bumped ureq to 3.x but the AgentBuilder-based webhook sender was not ported (branch update raced the merge). ureq 3 replaces AgentBuilder with Agent::config_builder(); timeouts are Option-wrapped and status() returns http::StatusCode.
This commit is contained in:
parent
77195eb7d8
commit
42fe8c3083
1 changed files with 6 additions and 5 deletions
|
|
@ -403,16 +403,17 @@ fn run_notification_command(_program: &str, _args: &[String]) -> Result<()> {
|
|||
|
||||
#[cfg(not(test))]
|
||||
fn send_webhook_request(target: &WebhookTarget, payload: serde_json::Value) -> Result<()> {
|
||||
let agent = ureq::AgentBuilder::new()
|
||||
.timeout_connect(std::time::Duration::from_secs(5))
|
||||
.timeout_read(std::time::Duration::from_secs(5))
|
||||
.build();
|
||||
let agent = ureq::Agent::config_builder()
|
||||
.timeout_connect(Some(std::time::Duration::from_secs(5)))
|
||||
.timeout_recv_response(Some(std::time::Duration::from_secs(5)))
|
||||
.build()
|
||||
.new_agent();
|
||||
let response = agent
|
||||
.post(&target.url)
|
||||
.send_json(payload)
|
||||
.with_context(|| format!("POST {}", target.url))?;
|
||||
|
||||
if response.status() >= 200 && response.status() < 300 {
|
||||
if response.status().is_success() {
|
||||
Ok(())
|
||||
} else {
|
||||
anyhow::bail!("{} returned {}", target.url, response.status());
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue