From 1422e3bebcda42fbffcd76c56d871dfd35a83530 Mon Sep 17 00:00:00 2001 From: paulobressan Date: Mon, 9 Mar 2026 12:44:20 -0300 Subject: [PATCH 1/2] feat(webhook/sink): implement http request for reset action --- src/sinks/webhook.rs | 41 ++++++++++++++++++++++++++--------------- 1 file changed, 26 insertions(+), 15 deletions(-) diff --git a/src/sinks/webhook.rs b/src/sinks/webhook.rs index d0a3aaf9..374ff596 100644 --- a/src/sinks/webhook.rs +++ b/src/sinks/webhook.rs @@ -41,27 +41,38 @@ impl gasket::framework::Worker for Worker { async fn execute(&mut self, unit: &ChainEvent, stage: &mut Stage) -> Result<(), WorkerError> { let point = unit.point().clone(); - let record = unit.record().cloned(); - - if record.is_none() { - return Ok(()); - } - - let body = serde_json::Value::from(record.unwrap()); let point_header = match &point { Point::Origin => String::from("origin"), Point::Specific(a, b) => format!("{a},{}", hex::encode(b)), }; - let request = self - .client - .post(&stage.config.url) - .header("x-oura-chainsync-action", "apply") - .header("x-oura-chainsync-point", point_header) - .json(&body) - .build() - .or_panic()?; + let request = match unit { + ChainEvent::Apply(_, record) => { + let body = serde_json::Value::from(record.clone()); + self.client + .post(&stage.config.url) + .header("x-oura-chainsync-action", "apply") + .header("x-oura-chainsync-point", point_header) + .json(&body) + } + ChainEvent::Undo(_, record) => { + let body = serde_json::Value::from(record.clone()); + self.client + .post(&stage.config.url) + .header("x-oura-chainsync-action", "undo") + .header("x-oura-chainsync-point", point_header) + .json(&body) + } + + ChainEvent::Reset(_) => self + .client + .post(&stage.config.url) + .header("x-oura-chainsync-action", "reset") + .header("x-oura-chainsync-point", point_header), + } + .build() + .or_panic()?; self.client .execute(request) From cc7e57a7de7f4b2b488bad014331941299fb3d20 Mon Sep 17 00:00:00 2001 From: paulobressan Date: Mon, 9 Mar 2026 13:27:48 -0300 Subject: [PATCH 2/2] chore: add reset body --- src/sinks/webhook.rs | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/src/sinks/webhook.rs b/src/sinks/webhook.rs index 374ff596..40ee5fc4 100644 --- a/src/sinks/webhook.rs +++ b/src/sinks/webhook.rs @@ -64,12 +64,24 @@ impl gasket::framework::Worker for Worker { .header("x-oura-chainsync-point", point_header) .json(&body) } + ChainEvent::Reset(_) => { + let body = serde_json::json!({ + "event": "reset", + "point": match &point { + Point::Origin => serde_json::Value::from("origin"), + Point::Specific(slot, hash) => serde_json::json!({ + "slot": slot, + "hash": hex::encode(hash), + }), + } + }); - ChainEvent::Reset(_) => self - .client - .post(&stage.config.url) - .header("x-oura-chainsync-action", "reset") - .header("x-oura-chainsync-point", point_header), + self.client + .post(&stage.config.url) + .header("x-oura-chainsync-action", "reset") + .header("x-oura-chainsync-point", point_header) + .json(&body) + } } .build() .or_panic()?;